В этой статье описывается продвинутый метод перетаскивания, который JS реализует совместимый с различными браузерами. Поделитесь этим для вашей ссылки, следующим образом:
<! Doctype html public "-// w3c // dtd html 4.01 // en" "http://www.w3.org/tr/html4/strict.dtd"> <html> <Head> <meta http-equiv = "content-type" content = "text/html; перетаскивать </title> <style> #tobedraged {width: 100px; высота: 100px; высота линии: 100px; Граница: 1px твердый красный; позиция: абсолютно; Текст-альбом: Центр; Семейство шрифта: Arial, Helvetica, Sans-Serif; курсор: двигаться; } </style> <script type = "text/javascript"> window.onload = function () {dodrag (); } function dodrag () {var div = document.getElementbyId ("tobedRed"); var posx; var posy; div.onmousedown = function (e) {var e = e || window.event; if (div.setCapture) {div.setCapture (); } posx = e.clientx - parseint (div.offsetleft); posy = e.clienty - parseint (div.offsettop); document.onmouseMove = function (ev) {var ev = ev || window.event; // Если это ie if (ev.setcapture) {} div.style.left = (ev.clientx - posx)+"px"; div.style.top = (ev.clienty - posy)+"px"; } document.onmouseup = function () {document.onmouseMove = null; document.onmouseup = null; if (div.ReleaseCapture) {div.ReleaseCapture (); }}}}} </script> </head> <body> <div id = "tobedred"> вы перетаскиваете меня! </div> </body> </html>For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm skills", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm skills", "Summary of Алгоритмы и методы обхода JavaScript »и« Сводка использования математических операций JavaScript ».
Я надеюсь, что эта статья будет полезна для каждого программирования JavaScript.