The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Javascript code help?

View previous topic View next topic Go down

Solved Javascript code help?

Post by ThePhantomHourglass on 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



This is what the notification box would look like:


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

ThePhantomHourglass
New Member

Male Posts : 11
Reputation : 1
Language : English

http://aresiiocorpforums.forumotion.com/

Back to top Go down

Solved Re: Javascript code help?

Post by Ange Tuteur on 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 ?

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Javascript code help?

Post by ThePhantomHourglass on 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.

ThePhantomHourglass
New Member

Male Posts : 11
Reputation : 1
Language : English

http://aresiiocorpforums.forumotion.com/

Back to top Go down

Solved Re: Javascript code help?

Post by Ange Tuteur on 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>')
});

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Javascript code help?

Post by ThePhantomHourglass on 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?

ThePhantomHourglass
New Member

Male Posts : 11
Reputation : 1
Language : English

http://aresiiocorpforums.forumotion.com/

Back to top Go down

Solved Re: Javascript code help?

Post by Ange Tuteur on 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.

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Javascript code help?

Post by ThePhantomHourglass on 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.

ThePhantomHourglass
New Member

Male Posts : 11
Reputation : 1
Language : English

http://aresiiocorpforums.forumotion.com/

Back to top Go down

Solved Re: Javascript code help?

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

You're welcome I love you

Topic solved and archived

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum