Scripts

A scrolling banner following the mouse pointer

There are many reasons to display a scrolling banner on a page. For thanks, ads, exceptional events, eye-catching message, etc. This banner will stick to the cursor except when defined otherwise in the script.

To obtain this effect, insert the following script between the <body> and </body> tags. You can customise your message (variable scroller_msg) and the display duration (variable dismissafter). If the value for duration is 0, the message will display continuously.



<SCRIPT language="JavaScript1.2">
<!--

var scroller_msg='Welcome to our site!'
var dismissafter=0

var initialvisible=0
if (document.all)
document.write('<marquee id="curscroll" style="position:absolute;width:150px;border:1px solid black;font-size:14px;background-color:white;visibility:hidden">'+scroller_msg+'</marquee>')

function followcursor(){
//move cursor function for IE

if (initialvisible==0){
curscroll.style.visibility="visible"
initialvisible=1
}

curscroll.style.left=document.body.scrollLeft+event.clientX+10
curscroll.style.top=document.body.scrollTop+event.clientY+10
}

function dismissmessage(){
curscroll.style.visibility="hidden"
}


if (document.all){
document.onmousemove=followcursor
document.ondblclick=dismissmessage
if (dismissafter!=0)
setTimeout("dismissmessage()",dismissafter*1000)
}

//-->
</SCRIPT>

All you need to do now is to initialise the effect through the <body> tag, as follows:

<Body style="width:100%;overflow-x:hidden;overflow-y:scroll">

Discover all Webmaster scripts.