View Full Version : Needed: show message once at the top script

02-11-2013, 01:19 AM
I need something similar to what http://monster.com has. If you visit it you will notice how the whole page is pushed down by a yellow bar with a text at the top of the page. It's cookie based and once it's closed it doesn't show up again.

I found drop down boxes, sticky notes, etc. scripts on DD, but nothing similar to this one.

Can you guys point me in the right direction where I can find a script like that? Or maybe you have one in your own library?

Thank you!

02-11-2013, 11:25 PM
var alertmessage="This is an alert."

function prompt_once_per_session()
if( !/(^|\s|;)seenAlert=yes(;|\s|$)/.test(document.cookie))
{if( !confirm(alertmessage+'\n\nClick on OK if you don`t want this message to show again.\n\nClick on CANCEL if you want this message to show each time you load this page.') )
else {document.cookie="seenAlert=yes";}

if ( typeof window.addEventListener != "undefined" )
window.addEventListener( "load", prompt_once_per_session, false );
else if ( typeof window.attachEvent != "undefined" )
window.attachEvent( "onload", prompt_once_per_session);
else {
if ( window.onload != null ) {
var oldOnload = window.onload;
window.onload = function ( e ) {
oldOnload( e );
window.onload = prompt_once_per_session;

02-11-2013, 11:43 PM
molendijk, this is just another popup. I need something that will work like here: http://monster.com

Notice the yellow bar that pushes the site down...

02-12-2013, 08:35 PM
I don't see a yellow bar. But couldn't you just create one with a close button in it? It could be a div with id="show_once". Then using onclick="document.getElementById('show_once').style.display='none'" on the button will hide the div. No cookies needed, I think.