Code: Short jsdiv layer dragging implementation code [compatible with IE and Firefox] _ javascript skills

Source: Internet
Author: User
The code is short, and the jsdiv layer is dragged to implement the Code [compatible with IE and Firefox]. For more information, see.

<Script type = "text/javascript"> var ie = document. all; var nn6 = document. getElementById &&! Document. all; var isdrag = false; var x, y; var dobj; function movemouse (e) {if (isdrag) {dobj. style. left = nn6? Tx + e. clientX-x: tx + event. clientX-x; dobj. style. top = nn6? Ty + e. clientY-y: ty + event. clientY-y; return false ;}} function selectmouse (e) {var fobj = nn6? E.tar get: event. srcElement; var topelement = nn6? "HTML": "BODY"; while (fobj. tagName! = Topelement & fobj. className! = "Dragme") {fobj = nn6? Fobj. parentNode: fobj. parentElement;} if (fobj. className = "dragme") {isdrag = true; dobj = fobj; tx = parseInt (dobj. style. left + 0); ty = parseInt (dobj. style. top + 0); x = nn6? E. clientX: event. clientX; y = nn6? E. clientY: event. clientY; document. onmousemove = movemouse; return false ;}} document. onmousedown = selectmouse; document. onmouseup = new Function ("isdrag = false"); script <p align = "center"> </p>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

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.