<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" > <ptml> <pead> <title> New Document &L t;/title> <meta name= "generator" content= "EditPlus" > <meta name= "Author" content= "" > <meta name= "Key Words "content=" "> <meta name=" Description "content=" "> </pead> <body onmousemove=" Getxy (event) > <script language= "JavaScript" > <!--function MouseX (evt) {if (Evt.pagex) return evt.pagex; else if (EVT.CLIENTX) return Evt.clientx + (document.documentElement.scrollLeft?) Document.documentElement.scrollLeft:document.body.scrollLeft); else return null; function Mousey (evt) {if (evt.pagey) return evt.pagey; else if (Evt.clienty) return evt.clienty + (Document.documentElement.scrollTop?) DOCUMENT.DOCUMENTELEMENT.SCROLLTOP:DOCUMENT.BODY.SCROLLTOP); else return null; function Getxy (event) {var e = event | | window.event; var x = MouseX (e); var y = Mousey (e); document.getElementById ("XY"). InnerHTML = "x:" + x + "<br>y:" + Y; function GetX (elementid) {var el = elementid return el.offsetleft} function GetY (ElementID) {var el = element ID return el.offsettop} function Getelementpositionx (elemid) {var offsettrail = document.getElementById (elemid); var offsetleft = 0; while (Offsettrail) {offsetleft + = Offsettrail.offsetleft; Offsettrail = offsettrail.offsetparent; } if (Navigator.userAgent.indexOf ("Mac")!=-1 && typeof (Document.body.leftMargin)!= "undefined") {offsetleft + + Document.body.leftMargin; return offsetleft; function Getelementpositiony (elemid) {var offsettrail = document.getElementById (elemid); var offsettop = 0; while (Offsettrail) {offsettop + = Offsettrail.offsettop; Offsettrail = offsettrail.offsetparent; } if (Navigator.userAgent.indexOf ("Mac")!=-1 && typeof (Document.body.leftMargin)!= "undefined") {offsettop + + Document.body.topMargin; return offsettop; } function GetelEmentpositionxy (elemid) {var offsettrail = Elemid; var offsetleft = 24; var offsettop = 0; while (Offsettrail) {offsetleft + = Offsettrail.offsetleft; offsettop + = Offsettrail.offsettop; Offsettrail = offsettrail.offsetparent; } if (Navigator.userAgent.indexOf ("Mac")!=-1 && typeof (Document.body.leftMargin)!= "undefined") {offsetleft + + Document.body.leftMargin; Offsetleft + = Document.body.leftMargin; } document.getElementById ("Txt_left"). innertext = Offsetleft; document.getElementById ("Txt_top"). innertext = offsettop; document.getElementById ("Divmsg"). Style.top = offsettop + "px"; //--> </script> Mouse Absolute position:<br> <span id= "XY" ></span><br><br> control input box Txtpos absolute position :<br> x:<span id= "Txt_left" ></span><br> y:<span id= "Txt_top" ></span><br> <input type= "text" name= "Txtpos" id= "Txtpos" onfocus= "Getelementpositionxy (This)"/> <br><br> < Div id= "Divmsg" ></div> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]