A: The History object
<!doctype html>
<meta charset= "Utf-8" >
<title> Untitled Document </title>
<script type= "Text/javascript" >
History object records URL of user access
function Myback () {
Window.alert (history.length);
Window.history.go (-1);
}
</script>
<body>
<input type= "button" onclick= "Myback ()" value= "Back to last page 1"/>
</body>
II: Location Object
<script type= "Text/javascript" >
The Location object contains information about the current URL
function Myfresh () {
Window.location.reload ();
}
Refresh the page every 10 seconds
Window.setinterval ("Myfresh ()", 10000);
</script>
Three: Navigator Object
<script type= "Text/javascript" >
Navigator This object includes information about the browser and wants to see all the properties under that object can be obtained through traversal.
for (var key in navigator) {
document.write ("<br>" +key+ "=" +navigator[key]);
}
</script>
Four: Event object
Case One:
<script type= "Text/javascript" >
var i=5;
function Counttime () {
i--;
Mybut.value= "Agree" +i;
if (i==0) {
Mybut.disabled=false;
Window.clearinterval (MyTimer);
}
}
var mytimer=window.setinterval ("Counttime
() ", 1000);
</script>
<body>
<P>
Registration terms
</p>
<input type= "button" id= "Mybut" disabled= "true" value= "Agree 5" >
</body>
case TWO: detecting mouse movement
<script type= "Text/javascript" >
function Test () {
showxy.innertext= "x=" +window.event.screenx+ "y=" +window.event.screeny;
}
</script>
<body>
<div onmousemove= "Test ();" style= "width:400px;height:300px;border:1px solid red;" >
</div>
<span id= "Showxy" ></span>
</body>
Case Three:
<script type= "Text/javascript" >
Enter a six-digit number in the text box, the first digit cannot be 0, cannot exceed the six-digit number, must be all numbers,
var i=0;
function Checknum (obj) {
if (i==6) {
Window.alert ("Input string length >6");
return false;
}
The first one can't be 0.
if (i==0) {
if (window.event.keycode== ' 0 '. charCodeAt (0)) {
Alert (' The first cannot be 0 ');
return false;
}
}
if (window.event.keycode< ' 0 '. charCodeAt (0) | | Window.event.keycode> ' 9 '. charCodeAt (0)) {
Alert ("You don't enter a number");
return false;
}else{
i++;
}
}
</script>
<body>
Please enter a six-digit number <input type= "text" id= "Pagenow" onkeydown= "return Checknum (This)"/>
</body>
Copyright Notice: Bo Master original articles, reproduced please indicate the source. Http://blog.csdn.net/dzy21
JavaScript DOM Programming (2): Common objects 1