Picture follows mouse movement (Lite cross browser implementation)

Source: Internet
Author: User

Online to see a lot of pictures to follow the mouse movement, the sense of code is very complex, not compatible, in fact, can be very simple to achieve:

<!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd "><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=gb2312"><title>Picture following mouse</title></Head><Body><Scripttype= "Text/javascript">    functionDomousemove (e) {varevt=e||window.event; varx=Evt.clentx||Evt.x; vary=Evt.clenty||Evt.y; LayerName= 'IIT'; varcurelement=document.getElementById ("Myimg"); CurElement.style.left=x+"px"; CurElement.style.top=y+"px"; } document.onmousemove=Domousemove;</Script>        <DivID= "Mydiv">        <imgID= "Myimg"src= "Img/a2.jpg"STYLE= "Position:absolute; top:0pt; left:0pt;width=103;height=28; Z-index:2; ">        </Div></Body></HTML>

At present Document.layers has been dead, look forward to document.all early on the West!!

Picture follows mouse movement (Lite cross browser implementation)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.