GB_001 Posted May 22, 2010 Share Posted May 22, 2010 Hello, How would I be able to put a box around the cursor using javascript? Thankyou, GB Quote Link to comment Share on other sites More sharing options...
ignace Posted May 22, 2010 Share Posted May 22, 2010 You can't. You can however create your own image and change the default: cursor: url(my-cursor.cur); Quote Link to comment Share on other sites More sharing options...
Ang3l0fDeath Posted May 23, 2010 Share Posted May 23, 2010 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. } */ Quote Link to comment Share on other sites More sharing options...
ignace Posted May 23, 2010 Share Posted May 23, 2010 Attaching a DIV to your mouse cursor may have some nasty effects on your design. Quote Link to comment Share on other sites More sharing options...
GB_001 Posted May 23, 2010 Author Share Posted May 23, 2010 Thankyou, I'd rather create my own image though as it might interfere with the design. Quote Link to comment Share on other sites More sharing options...
Ang3l0fDeath Posted May 24, 2010 Share Posted May 24, 2010 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.