Requirements:
1. Pop-up confirmation box when new window opens, open
Use if to determine whether the confirmation box clicked OK, such as clicking the Popup Input dialog box, otherwise there is no action.
2, through the Input dialog box, determine the open URL, the default is http://www.imooc.com/
3, open the window requirements, 400 pixels wide, 500 pixels high, no menu bar, no toolbar.
1<! DOCTYPE html>234<title>NewDocument </title>5<meta http-equiv= "Content-type" content= "text/html; CHARSET=GBK "/>6<script type= "Text/javascript" >7 8 //A new window opens with a confirmation box open9 Ten //by entering the dialog box, determine the open URL, default to http://www.imooc.com/ One A //The open window requires a width of 400 pixels, a height of 500 pixels, no menu bar, no toolbars. - functionOpenwindow () { - varMymessage=confirm ("Open a website?"));//confirm usage the if(mymessage==true) - { - varOpen=prompt ("Please input a website name", "http://www.imooc.com");//prompt dialog box Usage - + window.open (open); - + } A Else at { -document.write ("null") - } - } - -</script> in -<body> to<input type= "button" value= "new window open Web site" onclick= "Openwindow ()"/> +</body> -"JS Learning" Web 2-7 Exercises: Create a New button, "New window open Web site", click to open a new window.