Before you read this article, you can read the offsetleft, offsettop, Offsetwidth, offsetheight properties of JavaScript Drag & Drop Series 2 to clarify the context.
Okay, let's get to the point.
The same properties/methods as the model
1 Button Properties
An integer type that can be read and writable. For a specific mouse event, the mouse button is pressed, it can be dragged and dragged, to determine whether the left mouse button to raise the MouseDown event. All of its values and its meaning (refer to the JavaScript Advanced programming) Well, let's get to the point.
3.1 E/window. Properties/Methods of event object
The 3.1.1 IE event model and DOM events are as follows:
0-the button is not pressed
1-Press the left button
2-Press the right button
3-Press the left and right buttons at the same time
4-Press the middle button
5-Press the left and middle keys
6-Press the right button and the middle key
7 Press the left and right button at the same time
The MouseUp button property returns the exact same value as in the MouseDown event.
Note: In all browsers that are compatible with the DOM event model, 0 indicates that the left key is pressed, the value 1 does not exist, and 2 indicates that the right button is pressed, and for non-mouse events, return "undefined".
2 ClientX, Clienty properties
Both of these properties are of type Integer, in pixels, readable and writable. Represents the x-coordinate and y-coordinate of the mouse in the client area of the browser (excluding toolbars, scroll bars, and so on) when related events occur. A picture to explain the best, please see:
Figure 3.1:clientx and Clienty properties
The following code is a very simple example that can locate the coordinates of the mouse at any time and display the results in two text boxes, and if you want, you can try to run it, compatible with all of the current modern browsers.
Example code 1:
--><!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD">
<Html>
<Head>
<MetaHttp-equiv= "Content-type"Content= "text/html; Charset=utf-8 " />
<Title>Untitled Document</Title>
<StyleType= "Text/css">
Body{
Border:1px solid Black;
Margin:0px;
}
</Style>
<ScriptType= "Text/javascript"Language= "JavaScript">
Document.onmousemove=Move
functionMove (e) {
If(!E
{
E=window.event;
}
VarXElement=document.getElementById ("X");
VarYelement=document.getElementById ("Y");
Xelement.value=E.clientx;
Yelement.value=E.clienty;
}
</ script
</ head "
" ""
input type = "text" id = "x" value = " />
input type = "text" id = "y" value = " />
</ body ,
</ html
3 type Property
Current 1/4 page
1 234 Next read the full text