<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" <title> New D Ocument </title> <meta name= "generator" content= "EditPlus" <meta name= "Author" content= "" > <meta name= "Keywords" content= "" <meta name= "Description" " content=; <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 = ElementID 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> Absolute position of mouse: <br/> <span id= "XY" style= "color:red;" ></span><br/><br/> The absolute position of the control input box Txtpos: <br/> X:<span id= "Txt_left" style= "color:red;" ></span><br/> Y:<span id= "Txt_top" style= "color:red;" ></span><br/> <input type= "text" name= "Txtpos" id= "Txtpos" onfocus= "Getelementpositionxy (This)"/> <br/><br/> <div id= "divmsg" style= "Height:60px;width:100px;background-color: #cccccc" ></div> </body>
|