廢話不多說了,直接貼代碼了。
具體代碼如下所示:
<script>
function openWindow(){
var my=confirm("你要打開窗口嗎?")
if(my==true){
var url=prompt("通過輸入對話框,確定打開的網址","http://www.imooc.com")
if(url!=null){
window.open('htttp://www.refw.org.cn','_blank','width=300,height=300,scrollbars=no,menubar=no')}
else{
alert('不打開');
} /*if嵌套*/
}
else{
alert("88")
}
}
</script>
<body>
<input type="button" onclick="openWindow()" value="點擊">
</body>
代碼就這麼簡單幾句,有任何疑問歡迎給我留言,小編會及時給大家回復的!