<!DOCTYPE html><html> <head> <title> new document </title> <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> <script type="text/javascript"> function openWindow(){ var a = confirm("确定打开新窗口?");//新窗口打开时弹出确认框,是否打开 if(a==true){ var youurl = prompt("请输入需要打开的网址!","http://"); if(youurl!=null){ //通过输入对话框,打开输入的网址 window.open( youurl ,'_blank','width=400,height=500,menubar=yes,toolbar=yes'); } else{ //如果不输入则默认打开http://www.imooc.com/ window.open('http://www.imooc.com','_blank','width=400,height=500,menubar=yes,toolbar=yes'); } } else{ document.write("打开失败!"); } }; </script> </head> <body> <input type="button" value="新窗口打开网站" onclick="openWindow()" /> </body></html>