First, JavaScript basic syntax.
(a) Data type and variable type. Integer, Decimal, Layout, string, datetime, array cast: parseint () parsefloat () IsNaN ()
(b) array var array name = new Array ([length]); "Counterfeit" array a.length-length a[subscript] = value. a[Subscript]
(c) function
Function name (formal parameter)
{
}
function Showstr (a)
{
}
Second, Dom operation
Dom-document the object Model document. Tree
Linear model, tree-shaped model, mesh model
Window
History
Location
Document
Head
Body
A,img,table,ul,ol .....
Status
The verb of the noun behavior of the object--object characteristic
(i) window 1.alert () Window.alert ();
2.[var a =]window.confirm ("Can you run over the leopard?" "); Prompt (); --infrequently used, no need to remember, input
3.open (); Open ("Address", "_blank/_self", "new Window Features"); [var a =]window.open ("http://www.sina.com.cn"); Open the page in a new window and return to the new window. A is also a variable of window type. Detailed translation required.
4.close (); Window.close ();
5.setTimeout ("code", milliseconds) after the specified number of milliseconds, execute code once.
Example
<Scriptlanguage= "JavaScript">functionShowTime () {varDate= NewDate (); document.getElementById ("hh"). InnerHTML=date; Window.settimeout ("showTime ()", +); }window.settimeout ("showTime ()", +);</Script>
Practice
Make a page that appears in 5 seconds after Sina homepage
<Scriptlanguage= "JavaScript">varA;functionOpenad () {a=window.open ("http://www.sina.com.cn","_blank","width=200 height=200 toolbar=no top=0 left=0"); Window.settimeout ("Closead ()", the);}functionClosead () {a.close ();} Window.settimeout ("Openad ()", the);</Script>
javascript--scripting language