The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
2 posters

    Javascript code help?

    ThePhantomHourglass
    ThePhantomHourglass
    New Member


    Male Posts : 11
    Reputation : 1
    Language : English

    Solved Javascript code help?

    Post by ThePhantomHourglass March 6th 2014, 10:05 pm

    What I want to do is make a JavaScript code in the JavaScript code management area thingy. What I want the code to do, is to set a certain warning message on the top of the page* that displays a custom text message in a red box.

    *What I mean by top of the page:
    The box would go where the red box is currently surrounding in the image below
    Javascript code help? Ozawnw10


    This is what the notification box would look like:
    Javascript code help? Gbejld10


    Last edited by ThePhantomHourglass on March 6th 2014, 11:27 pm; edited 1 time in total
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Javascript code help?

    Post by Ange Tuteur March 6th 2014, 10:34 pm

    Hello ThePhantomHourglass,

    The announcements should already show on all the pages. What exactly would you like the code to do ?
    ThePhantomHourglass
    ThePhantomHourglass
    New Member


    Male Posts : 11
    Reputation : 1
    Language : English

    Solved Re: Javascript code help?

    Post by ThePhantomHourglass March 6th 2014, 10:45 pm

    Ange Tuteur wrote:Hello ThePhantomHourglass,

    The announcements should already show on all the pages. What exactly would you like the code to do ?
    For it to do the same but with that box. I'll have Announcements disabled and I'll change the announcement text via the code.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Javascript code help?

    Post by Ange Tuteur March 6th 2014, 10:53 pm

    Okay, try this :
    * tick in all the pages
    Code:
    $(function() {
     Â   var message = 'Message content';
     Â   $('#pun-head').after('<div class="module main"><div class="main-content clearfix">'+message+'</div></div>')
    });
    ThePhantomHourglass
    ThePhantomHourglass
    New Member


    Male Posts : 11
    Reputation : 1
    Language : English

    Solved Re: Javascript code help?

    Post by ThePhantomHourglass March 6th 2014, 10:59 pm

    Ange Tuteur wrote:Okay, try this :
    * tick in all the pages
    Code:
    $(function() {
     Â   var message = 'Message content';
     Â   $('#pun-head').after('<div class="module main"><div class="main-content clearfix">'+message+'</div></div>')
    });
    Awesome, thanks! It works. One last thing, how would I get the text to be centered, colored white, size 16px font, and the box to be red (#FF0000) with a black border?
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Javascript code help?

    Post by Ange Tuteur March 6th 2014, 11:16 pm

    Try this :
    Code:
    $(function() {
     Â   var settings = {
     Â       message : 'Message content',
     Â       style : 'text-align:center;color:white;font-size:16px;font-weight:bold;border:2px solid black;',
     Â       innerstyle : 'background:red;border:none;'
     Â   };
     Â   
     Â   $('#pun-head').after('<div class="module main" style="'+settings["style"]+'"><div class="main-content clearfix" style="'+settings["innerstyle"]+'">'+settings["message"]+'</div></div>');
     Â   
    });

    I've added some settings to edit the box style. You can also use HTML in the message content.
    ThePhantomHourglass
    ThePhantomHourglass
    New Member


    Male Posts : 11
    Reputation : 1
    Language : English

    Solved Re: Javascript code help?

    Post by ThePhantomHourglass March 6th 2014, 11:26 pm

    Ange Tuteur wrote:Try this :
    Code:
    $(function() {
     Â   var settings = {
     Â       message : 'Message content',
     Â       style : 'text-align:center;color:white;font-size:16px;font-weight:bold;border:2px solid black;',
     Â       innerstyle : 'background:red;border:none;'
     Â   };
     Â   
     Â   $('#pun-head').after('<div class="module main" style="'+settings["style"]+'"><div class="main-content clearfix" style="'+settings["innerstyle"]+'">'+settings["message"]+'</div></div>');
     Â   
    });

    I've added some settings to edit the box style. You can also use HTML in the message content.
    It works! Thank you very much for helping me.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Javascript code help?

    Post by Ange Tuteur March 6th 2014, 11:45 pm

    You're welcome I love you

    Topic solved and archived

      Current date/time is November 11th 2024, 6:10 pm