First, popup box
A. Prompt box
alert ();
B. Input box
Prompt ();
C. Confirmation Box
Confirm ();
var flag= confirm ("Confirm delete?" ");
Second, JS program debugging
Check console console for errors first
Browser Debug
alert ();
Console.log ();
Third, function
System functions:
parseint (); A string that converts the first character to a number
Number (); A string that converts only numbers
IsNaN (); Is isn't a number///Is it a non-numeric?
Custom functions:
A, funtion method name (parameter 1, parameter 2 ...) {
Return
}
Funtion Show (str,age) {}
public void Show (String str,int age) {
}
B. Var method name =function (parameter 1, parameter 2 ...) {
return value
}
Invoking the JS code in a hyperlink
<a href= "JAVASCRIPT:SF (); > Please click </a>
Iv. events commonly used in JS
OnLoad//Page load complete execution
OnClick//Mouse click event
onmouseover//Mouse over events
onmouseout//Mouse Move Event
onfocus//Focus Input Box Event
onblur//Remove input box events
OnKeyDown Keyboard press Event
Carriage return Event:
Document.onkeydown=function (e) {
if (e.keycode==13) {//Enter
Alert ("Login! ");
}
}
onchange;//drop-down box toggle Event
<select onchange= "alert (' dropdown box changed ');" >
<option> Beijing </option>
<option> Shenzhen </option>
<option> Hefei </option>
</select>
onsubmit;//Form Submission Events
V. Browser object Model
Window object (general ellipsis not written)
Window.onload = function () {
}
Common Properties
History
Window.history.go (-1);//Return to previous page
History.go (0);//Refresh
Window.history.go (1);//Next page
Location
Location.reload ();//Refresh
Jump page:
Window.location.href = "http://www.bdqn.cn";
Common methods:
Alert ();p rompt (); Confirm ();
Opens a new window open ();
Close: Close ();
jquery with the Tang notes