One, JS Browser object-window Object
1. Functions can be called directly as objects, and window itself has some elements: Innerheight and Innerwidth
2.open () and close () functions
<Buttononclick= "Demo ()">Open</Button> <Script> functionDemo () {window.open ("window.html","Windowname","height=200,width=200"); } //document.write ("window width:" + window.innerwidth+ "<br>"); //document.write ("Window length:" +window.innerheight) </Script>
Two. Timer
1.setinterval() This is a counter function that executes the code of the first argument within the corresponding event
clearinterval () This function can be understood as a stopping device of a time
<PID= "P"></P> <ButtonID= "BTN"onclick= "Stop ()">Time to stop</Button> <Script> functionDemo () {varDate=NewDate ();//create an object of a time varT=date.tolocaletimestring ();//use the time object to get a local time .document.getElementById ("P"). InnerHTML=T; //gets the ID, output T on the original element } varMyTime=SetInterval (function() {demo ()}, +); //This function is re-calling the function after 1000 milliseconds and can be interpreted as refreshing functionStop () {clearinterval (mytime); //This is an object that clears the parameters of the function that invokes the timer } </Script>
2.setTimeout (): This is also a function of timing, but he can only call their own functions to achieve the effect of timing
Cleartimeout (): Clear
<ButtonID= "BTN"onclick= "Demo ()">Button</Button> <Script> varwin; Unction Demo () {Alert ("Forget her .!! "); Win=SetTimeout (function() {demo ()}, -); //duplicate output can be achieved only by invoking itself in its own case } </Script>
Third, JS Browser object-history Object
history对象函数
JavaScript history.go() 函数 -- 前进或后退指定的页面数
JavaScript history.back() 函数 -- 后退一页
JavaScript history.forward() 函数 -- 前进一页
<form> <inputtype= "text"ID= "T"> <ButtonID= "BTN"onclick= "Demo ()">Button</Button> </form> <Script> functionDemo () {varwin=document.getElementById ("T"). Value; if(Win=="Hello") {history.back (); } Else{alert ("input Error!!! "); }}
Four, JS Browser object-location Object
Five, Screen object
The Screen object contains information about the client display screens.
Note: There is no public standard applied to the screen object, but this object is supported by all browsers.
The JavaScript Browser object