Home > Web Front-end > JS Tutorial > Js mouse follow code small hand click instance method_javascript skills

Js mouse follow code small hand click instance method_javascript skills

WBOY
Release: 2016-05-16 17:33:41
Original
1483 people have browsed it

[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]<script> window.onload = function(){ var oCursor = document.getElementById("cursor"); document.onmousemove=function (ev){ var oEvent=ev||event, oWidth = document.documentElement.clientWidth, oHeight = document.documentElement.clientHeight, scrollTop=document.documentElement.scrollTop + oEvent.clientY, scrollLeft=document.documentElement.scrollLeft + oEvent.clientX; if(scrollTop > oHeight-oCursor.offsetHeight){ oCursor.style.top = oHeight-oCursor.offsetHeight+'px'; }else if(scrollTop < 0){ oCursor.style.top = 0; }else{ oCursor.style.top = scrollTop+'px'; } if(scrollLeft > oWidth-oCursor.offsetWidth){ oCursor.style.left = oWidth-oCursor.offsetWidth+'px'; }else{ oCursor.style.left = scrollLeft+'px'; } document.onmousedown = function(){ oCursor.innerHTML = "<img src='http://www.jb51.net/jscss/demoimg/201305/cursor_hover.png' / alt="Js mouse follow code small hand click instance method_javascript skills" >"; return false; } document.onmouseup = function(){ oCursor.innerHTML = "<img src='http://www.jb51.net/jscss/demoimg/201305/cursor.png' / alt="Js mouse follow code small hand click instance method_javascript skills" >"; } }; } </script>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template