1 <!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">2 <HTMLxmlns= "http://www.w3.org/1999/xhtml">3 <Head>4 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" />5 <title>Window Object method</title>6 <Script>7 window.onload=function(){8 //Open a new window and assign a value to a variable9 Subwindow=window.open ("http://www.baidu.com","name","height=200,width=300");//I didn't add Var in front of him, he became a global variable. Ten SetTimeout ('Location ()',1800); One SetTimeout ('Closew ();',4000);//timer, after 2 seconds, execute the CLOSEW function A } - functionClosew () { - subwindow.close (); the //the alert () method is also a method of the Window object, except that window can omit the - Window.alert ('pop up a prompt box'); - varBOOL=Window.confirm ('Are you sure you want to delete this piece of data? ');//Confirm method, user Click is put back ture, click Cancel to return False. - if(BOOL) + Alert ('your data is deleted successfully! '); - Else + Alert ('you have canceled data removal! '); A //Implement page Jumps at varAnswer=Window.prompt ("where are you reading?",'Ahnu');//returns a null or user-entered string value (NOT null) - if(Answer) - alert (answer); - Else - Alert ('The string you entered is empty'); - in - } to functionLocation () { + SubWindow.location.href="http://www.anshida.net"; - } the </Script> * </Head> $ <Body>Panax Notoginseng <spanID= "E">Hehe</span> - </Body> the </HTML>
Web instance: Please point me
Common Methods for Window objects