X: set or obtain the position of the outer boundary of the parent element of the mouse relative to the target event on the x coordinate.
ClientX: The x coordinate position of the client region, excluding the scroll bar, that is, the body area.
Offsetx: set or obtain the position of the inner boundary of the parent element of the mouse relative to the target event on the x coordinate.
ScreenX: relative to the user screen.
Test code 1:
[Code]
<Html>
<Head>
</Head>
<Script>
Function reload (){
Window. location. reload ("http://www.jb51.net ");
}
</Script>
<Body>
<Table>
<TR> <TD> <input type = "button" name = "button1" value = "button1" onclick = "reload (); "> </TD> </TR>
<TR> <TD> <input type = "button" name = "button2" value = "button2" onclick = "reload (); "> </TD> </TR>
</Table>
<Input type = "button" name = "update" value = "refresh" onclick = "reload ();">
<Br/>
<Input type = "button" name = "button" value = "button" onclick = "reload ();">
</Body>
</Html>
<Script>
Function window. onbeforeunload ()
{
Alert ('event. clientX = '+ event. clientX); // if you click the refresh button, it depends on the position when you click the mouse.
Alert ('event. offsetX = '+ event. offsetX );
Alert ('document. body. clientWidth = '+ document. body. clientWidth );
Alert ('event. clientY = '+ event. clientY );
Alert ('event. offsetY = '+ event. offsetY );
Alert ('event. altKey = '+ event. altKey );
If (event. clientX> document. body. clientWidth & event. clientY <0 | event. altKey)
{
Window. event. returnValue = "are you sure you want to exit this page? ";
} Else
{
Alert ("You are refreshing ");
}
}
</Script>
[/Html]
DEMO code 2:
<Table border = 1 cellpadding = 15 cellspacing = 15 style = "position: relative; left: 100; top: 100"> <tr> <td> Click here to show. </td> </tr> </table>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]