或许是最简洁且得体的答案了,我是说或许……
<!DOCTYPE html> <html> <head> <title>new window</title> <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> <script type="text/javascript"> function openWindow(){ var b = confirm("确定新建窗口?");// 新窗口打开时弹出确认框,是否打开 if(b){ var url=prompt("请输入网址:", "www.imooc.com");// 通过输入对话框, if(url != null){ window.open("http://"+url, '_blank', 'width=400px,height=500px,menubar=no,toolbar=no');//打开的窗口要求,宽400 } } } </script> </head> <body> <input type="button" value="新窗口打开网站" onclick="openWindow()"> </body> </html>