The JavaScript Browser object

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.