Jump to content

Box around cursor.


GB_001

Recommended Posts

You can put a box around the mouse cursor.

 

i would suggest a box.gif image for the box though.

function mouse_p(x_or_y){if (!e) var e = window.event;
var posx = 0;
    var posy = 0;
if (e.pageX || e.pageY){
	posx = e.pageX;
	posy = e.pageY;}
else if (e.clientX || e.clientY){
	posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
	posy = e.clientY + document.body.scrollTop  + document.documentElement.scrollTop;}
if(x_or_y==='y'){return posy;}
if(x_or_y==='x'){return posx;}

 

The code above will get the mouse location within the window your webpage is located.  This is used to get the X & Y location of your mouse, hope you remember algerbra for X & Y.  lol

 

Alright this part you will have to figure out how to do yourself next.  But you looking for a way to start your function, this can be done by a button or <body onload='start_function_1'>

 

/* start_function(){
// get the y & x location of the mouse
var x = function mouse_p('x');
var y = function mouse_p('y');
// have a DIV field somewhere, with an position=absolute / position:absolute; left:0; top:0; width:0; height:0;
// you might have to change size to fix your image height/width but DIV if i remember expands to fix the size of whatever content it has.
// no we are going to change the DIV position left:x; top:y; OR left:function mouse_p('x'); top:function mouse_p('y');
//  So now your Div moved to where the mouse is.
// However to keep the box moving with the mouse we got to constantly repeat this function start_function_1() repeatively.  You can set it to just excute again or set it on a timer.  But the more delayed the responce time of the function the more laggy it looks.  Also if this script is just excuted again at 0 mill-seconds it could lag up someones computer.  So be careful.  Some functions do some dont.


}
*/

Link to comment
Share on other sites

Ya plus i had an extra thought for ya.... like add a start and stop function to your mouse cursor.  Cause you can add in the extra feature of adding / changing images.  Example.  Like you click a button on your page, the mouse cursor would have like an explodion or fireworks, or it simply changes colors from gray to lime green.  Well good luck with your site lol

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.