1.String intercept: substr: Cut a few, substring: cut to where.
2.String operations, such as capitalization, lowercase, do not change by themselves, just exchange references in the stack
var str = "Hello world";
var STR5 = Str.touppercase ();
document.write (STR5);
Str doesn't change, it loses STR5.
3.String replacement (/Regular expression (fixed expression)/, "destination string");
"Wodemamawoainimamawoainimama"
STR (/mama/g, "Baba"); change all mama to Baba (g: All)
4. If you first run script in head (document.write (""))
Script, then, the contents of the body will be overwritten
Summary: The page does not have a tag element and can have write (); There is no, otherwise overwrite
5. Dynamic time Display error problem: A. Global variable problem st B.settimeout:o to lowercase.
Run only once: var s = setTimeout ("function", number of milliseconds);
Clear: cleartimeout (s)
Run multiple times: var s = setinterval ("function", number of milliseconds);
Clear: clearinterval (s)
6.window objects
A. The open () method and the <a href = "" > can open a new window,
Different: Open (you can set properties of the window), but hyperlinks are not.
B.window.location = "" (Location.href = "")
C. window.showModalDialog ("js03.html"): You can also open a
New window, but this window must be handled, otherwise it won't move
D.window.onload (function name ()): The function is to put all the pages of the explanation finished before running the program.
7.
History.go (-1): Fallback page
History.go (1): Forward page.
From page A to page B, forward to the event on page A, back on page b
, first click on a to B connection, then two forward back buttons are activated
8. Get a set of values by tag name
getElementById (id value);
Getelementsbyname ("Name value");
Getelementbytagname (standard signature);
Select as: Checked property to
tagname Example: Iterating through the array using the list <li> tags; note: use (object.innerhtml) when taking values
All tags without value are used with the innerHTML property
9. The purpose is: let the page things loaded, and then execute the JS code, in case the page things are overwritten.
Common: Window.onload = function () {
JS Code}
Infrequently used: function name () {} <body onload = "name ()" >
Security: window.onload = function () {
Gets the object of the button. onclick = function () {
The operation performed;
};
};
JS Notes-02