js in scorll, offset, mouse, keyboard events operation summary

1, scroll property onscroll family event and the onload event

onscroll event
onscroll event
onload event features:
onload event features

2, offset family property

offsetWidth / the offsetHeight acquired width and height of an element
comprising: a content + + padding border read-only property is the result of type Number
the clientWidth / acquired width and height of the clientHeight an element
comprising: content + Filler read-only property is the result of type Number
the getComputedStyle () Gets the non-line element within the actual result value of the style of type string
obj.style. acquires style inline elements actual style value is the result of type string

// js exercise progress bar Example
1, there are two boxes, and outside for storing the progress bar (width 200px), which is displayed in real time the progress bar (width 0)
2, the setInterval () method is repeated after every specified number of milliseconds after executing the expression, every 30 milliseconds 2px progress bar width increases, the progress of 1% increase every 30 ms,
3, when the length of the progress bar is equal to the width of the sleeve, to stop the function performed.

js progress bar instance practice

at offset property
offset acquisition offsetLeft left offset distance in the offset having a positioning element are not positioned in an element if the default from the body of the read-only attribute
offset offsetTop

3, the event object event

What events: the operation of certain page elements of
the event object: When an event is generated for page elements, will create an object of this object is the event object (the premise of the event object: an event occurs ) does not make sense event will produce different event Object
Event Object
variety of events:
mouse events: onmouse ... onclick
keyboard events: onkeyup onkeydown onkeypress (press the lift process)
page event: onload onunload
form events: onfocus onblur onchange onsubmit

Creating an event object compatible:
var || E = E Event; || left parameter is a parameter in the event handler

4, property (coordinate attributes) Mouse event object

pageX / pageY high version of the browser from the coordinate position of the window contents
clientX / clientY lower version of the browser from the coordinate position of the visible window of
x / y coordinate position of the low version of the browser window from the visible
inside offsetX / offsetY operating element biasing the distance shift amount
coordinate screenX / screenY distance to the screen

// get the mouse position
Mouse Gets position

// page to achieve the effect of dragging the mouse
Drag the mouse to achieve results page
button properties:
0 Left ie6: 1 Right 2 Left 4 Wheel
1 Wheel
2 Right-
extended writing a compatible function compatible button properties
Compatible Properties button

5, keyboard event object properties

Get keyboard keyCode value, ASCII character code value is extended:

Compatible e.keyCode || e.which

Function key return value is a Boolean value corresponding to the pressed function key is true otherwise returns to false
ctrlKey Ctrl key
altKey alt key
shiftKey shift key
Function keys

// chat dialog send key provided
Chat dialog box, the send key provided
// Top function
Top features

// Ceiling
Ceiling achieve js function

Guess you like

Origin blog.csdn.net/ZHANGJIN9546/article/details/92852421