Mouse Box

Written by @kerixa 21 August 2012

In this code, a box with a text inside follows the cursor. If the cursor stays in one place, this box also stays in the same place, and by moving the mouse cursor, this box follows it. You can use this code when you want your site name, or any other text, to be in front of the user's eyes or when you want to give a new message or alert to the user.

Code Snippet:

                                                
                                                <!-- this script is provided by www.javascriptfreecode.com coded by: Kerixa Inc. -->
<SCRIPT language="JavaScript"> 
var scroller_msg='W W W . javascriptfreecode . c o m'
var dismissafter=0
var initialvisible=0
if (document.all)
document.write('<marquee id="curscroll" style="position:absolute;width:100px;border:1px dotted silver; font-family:Tahoma;font-size:11px ;background-color:#eaeaea ;visibility:True">'+scroller_msg+'</marquee>')
function followcursor(){
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><a target='_blank' href='www.javascriptfreecode.com' style='font-size: 8pt; text-decoration: none'>JavaScript Best Codes</a>                                                
                                            

Example:


About @kerixa

I am Krishna Eydat. I studied Software Engineering at University of Waterloo in Canada. I lead a few tech companies. I am passionate about the way we are connected. I would like to be part of something big or be the big deal!

K

Comments


Here you can leave us commments. Let us know what you think about this code tutorial!

0 / 300

TRENDING POST
1
2
3
4
5
VISITORS
Online Users: 12
Recent Members: Shahmeer, coolcoco7, SmitaPatil25, owoboycute, 092010
advertisement 2