Chapter II: JavaScript operating BOM
window object's properties:
history:
Method:
the Back () before loading a URL history list of objects in the
forward () to load the next URL history list of objects
go () to load a history list of objects a specific URL
LOCATION:
property:
host sets or returns the host name and the URL of the current port number
hostname Sets or returns the current URL's hostname
href Sets or returns the full URL
method:
reload () reload the current document
replace () with a new document replace the current document
document:
attribute:
referrer URL returns the load current document
URL to return the current document URL
method:
getElementById returns a reference () for the first object has a specified id of
getElementsByName () returns the object with the specified name collection
the getElementsByTagName () returns a collection object with the specified name in the tag
window object:
prompt () displays the dialog can prompt the user to enter the
alert () is displayed with a warning message and an OK button box
confirm () with a display message, and a cancel button confirmation dialog
close () Closes browser window
open () opens a new browser window to load the given URL specified in the document
setTimeout () function call after a specified number of milliseconds or calculation expression
setInterval () in the specified period (in milliseconds) to call the function or expression
Date:
getDate () every day between the value of the Date object month ~ 31 is between. 1
getDay () Date object of each day of the week, which is a value between 0 and 6
getHours () Date object hours, the value 23 is between ~ 0
getMinutes () returns the number of minutes Date object, the value is between 59 ~ 0
the getSeconds () returns the seconds Date object whose value is between 59 ~ 0
the getMonth () returns the month Date object, the value is between. 11 ~ 0
the getFullYear () Date object year, a value of 4 digits
getTime () returns from a time (1970 on January 1) to The number of milliseconds
the Math:
ceil () logarithm rounded Math.ceil (25.5); return 26
Math.ceil (-25.5); returns -25
Floor () the logarithm rounded Math.floor (25.5); return 25
Math.floor (-25.5); returns -26
round () the number rounded to the nearest number Math.round (25.5); return 26 is
Math.round (-25.5); returns -26
random () returns a random number Math.random (between 0 and 1); for example: 0.6273608814137365
timers:
the setTimeout:
number // ms after the triggering
the setTimeout (function () {
/ * Alert ( 'Hongtao'); * /
}, 3000);
the setInterval:
// ms representing each trigger
var interval the = the setInterval (function () {
// create a Date object
var datetime a Date new new = ();
//01.getElementById () Gets the element with an id attribute value
var span = document.getElementById ( 'span01');
span.innerHTML = datetime;
}, 1000);
Case:
<Script type = "text / JavaScript">
var Time = 10;
var interval The;
triggered // Start button click
function Start () {
// each -1 second
interval The = the setInterval (function () {
TIME - ;
// assignment to span
document.getElementById ( 'Time') the innerHTML = Time;.
IF (Time <= 0) {
// stop the timer
the clearInterval (interval The);
}
}, 1000);
};
function sTOP () {
the clearInterval (interval The);
};
window object's properties:
history:
Method:
the Back () before loading a URL history list of objects in the
forward () to load the next URL history list of objects
go () to load a history list of objects a specific URL
LOCATION:
property:
host sets or returns the host name and the URL of the current port number
hostname Sets or returns the current URL's hostname
href Sets or returns the full URL
method:
reload () reload the current document
replace () with a new document replace the current document
document:
attribute:
referrer URL returns the load current document
URL to return the current document URL
method:
getElementById returns a reference () for the first object has a specified id of
getElementsByName () returns the object with the specified name collection
the getElementsByTagName () returns a collection object with the specified name in the tag
window object:
prompt () displays the dialog can prompt the user to enter the
alert () is displayed with a warning message and an OK button box
confirm () with a display message, and a cancel button confirmation dialog
close () Closes browser window
open () opens a new browser window to load the given URL specified in the document
setTimeout () function call after a specified number of milliseconds or calculation expression
setInterval () in the specified period (in milliseconds) to call the function or expression
Date:
getDate () every day between the value of the Date object month ~ 31 is between. 1
getDay () Date object of each day of the week, which is a value between 0 and 6
getHours () Date object hours, the value 23 is between ~ 0
getMinutes () returns the number of minutes Date object, the value is between 59 ~ 0
the getSeconds () returns the seconds Date object whose value is between 59 ~ 0
the getMonth () returns the month Date object, the value is between. 11 ~ 0
the getFullYear () Date object year, a value of 4 digits
getTime () returns from a time (1970 on January 1) to The number of milliseconds
the Math:
ceil () logarithm rounded Math.ceil (25.5); return 26
Math.ceil (-25.5); returns -25
Floor () the logarithm rounded Math.floor (25.5); return 25
Math.floor (-25.5); returns -26
round () the number rounded to the nearest number Math.round (25.5); return 26 is
Math.round (-25.5); returns -26
random () returns a random number Math.random (between 0 and 1); for example: 0.6273608814137365
timers:
the setTimeout:
number // ms after the triggering
the setTimeout (function () {
/ * Alert ( 'Hongtao'); * /
}, 3000);
the setInterval:
// ms representing each trigger
var interval the = the setInterval (function () {
// create a Date object
var datetime a Date new new = ();
//01.getElementById () Gets the element with an id attribute value
var span = document.getElementById ( 'span01');
span.innerHTML = datetime;
}, 1000);
Case:
<Script type = "text / JavaScript">
var Time = 10;
var interval The;
triggered // Start button click
function Start () {
// each -1 second
interval The = the setInterval (function () {
TIME - ;
// assignment to span
document.getElementById ( 'Time') the innerHTML = Time;.
IF (Time <= 0) {
// stop the timer
the clearInterval (interval The);
}
}, 1000);
};
function sTOP () {
the clearInterval (interval The);
};
</script>