1. Re-navigate to the specified address: navigate("http://www.jb51.net");
2,
(1. *setInterval executes the specified code at intervals. The first parameter is the string of the code, the second parameter is the interval time (unit: milliseconds), and the return value is the identifier of the timer. For example:
setInterval("alert('hello')",5000);
*clearInterval cancels the scheduled execution of setInterval, which is equivalent to Enabled=False in Timer. Because setInterval can set multiple timings, clearInterval must specify the identifier of the timer to clear, which is the return value of setInterval.
var intervalld= setInterval("alert('hello')",5000);
clearInterval(intervalld);
(2. setTimeout is also a scheduled execution, but it is not a scheduled execution like setInterval. Instead, it is only executed once after setting the time. clearTimeout is also a clearing timing.
It is easy to distinguish: Interval is timing; Timeout is timeout.
var timeoutld=setTimeout("alert('hello')",2000);
(3. Case: Realizing the effect of title bar revolving door, that is, the browser's title text scrolls to the right every 500ms
(1. onload: Triggered when the web page is loaded. The browser downloads the document and parses and executes it at the same time. It may happen that a certain element needs to be operated when JavaScript is executed. This element has not been loaded. If so, the operation must be done. The code is placed in the onload event of the body, or the JavaScript can be placed after the element. The onload event of the element is triggered when the element itself is loaded, and the onload in the body is completed.
(2. onunload: web page. Triggered after closing (or leaving). onbeforeunload: A confirmation message will pop up when the window leaves (such as moving forward, backward, or closing). For example: ? '">
4,
In addition to unique attributes, there are of course events for common HTML elements: onclick (click), ondblclick (double-click), onkeydown (key pressed), onkeyup (key released), onkeypress (click on the button) , onmousedown (mouse pressed), onmousemove (mouse moved), onmouseout (mouse leaves element range),
onmouseover (mouse moves to element range), onmouseup (mouse button released), etc.
5. Properties of window object
(1. window.location.href="http://www.sina.com.cn", redirect to the new address, has the same effect as the navigate method. window.location.reload() refreshes the page.
(2. window.event is a very important attribute, used to obtain information when an event occurs. Events are not limited to events of the window object. Events of all elements can obtain relevant information through the event attribute.
a. altKey attribute, boot type, indicates whether the alt key is pressed when an event occurs. Similar attributes include ctrlKey and shiftKey
b. clientX, clientY are the coordinates of the mouse in the client area (in the browser page) when events occur; screenX, screenY are the coordinates of the mouse on the screen when events occur; offsetX, offsetY are when events occur relative to the mouse relative to the event source ( Button button) coordinates.
c, returnValue attribute, if returnValue is set to false, the processing of the default event will be cancelled.
d, srcElement: Get the event source object
e, KeyCode: the key value when the time occurs
f, button: the mouse button when the time occurs, 1 is the left button, 2 is the right button, 3 is the left button keys simultaneously.
6. clipboardData object, operations on the pasteboard. clearData("Text") clears the pasteboard; getData("Text") reads the value of the pasteboard, and the return value is the content of the pasteboard; setData("Text",val), sets the value of the pasteboard.
(1. When copying, the oncopy method of body is triggered. Directly return false to prohibit copying.
Example 1: No copying
Example 3: Disable pasting into text box
Please enter your mobile phone number again: :
Example 4: Attached content when copying
function modifyClipboard(){
clipboardData.setData('Text',clipboardData.getData('Text') 'This article comes from the Blog Park Technology Zone, please indicate the source when reprinting.' location.href);
}
oncopy="setTimeout ('modifyClipboard()',100)".
The user will modify the content in the pasteboard 0.1 seconds after the copy action occurs. 100ms is just a common value, you can write 1000, 10, 50, 20... You cannot directly perform operations on the pasteboard in oncopy, so set a timer to execute it after 0.1 seconds, so that it is no longer on the oncopy execution call stack.
7. Page forward and backward: history operation history
window.history.back() goes back; window.history.forward() goes forward. You can also use window.history.go(-1) to move forward; window.history.go(1) to move backward.
Example 1:
8. Document attribute (the most complex attribute) document is an attribute of the window object. Because the window can be omitted when using the window object members, document is generally written directly.
(1. Write: Write content to the document. writeln is similar to write, except that a carriage return is added at the end (2.
(3. Code written in onclick and other events will flush out the content of the page, and will only be displayed when the page is loaded. During the write process, the write will be integrated with the original content (4.
Case 1:
var s = "aaa@163.com";
var regex = /(. )@(. )/;
var match = s.match(regex);
alert(RegExp. $1 ", server: " RegExp.$2);
Case 1:
Copy code
(k==46)||(k==8)||( k==189)||(k==109)||(k==190)||(k==110)|| (k>=48 &&
k<=57)||(k> =96 && k<=105)||(k>=37 && k<=40) . onkeydown="returnnumonKeyDown()" Do not write onkeydown="numonKeyDown()" to distinguish between event response functions and functions called by event response functions.
* Disable pasting (great Tester), to get the value in the pasteboard, and then traverse each character to see if it is a legal value. Pasting is only allowed if all are legal values, as long as there is an illegal value Pasting is prohibited. charAt, charCodeAt method to add thousandth place
* Left-aligned without thousandths when the focus is on, right-aligned when the focus is not: this.style.textAlign='right'