function openWindow(){ var open; var mymessage; mymessage = confirm("是否打开新网页?") if(mymessage) { open = prompt("请输入网址:","http://www.imooc.com/") window.open(open,"_blank","width = 400,height = 500,") } }
如果用户点击取消,open的值是null,还能打开吗
function openWindow(){ var fw = confirm('是否訪問慕課網?'); if (fw == true) { window.open('http://www.imooc.com/','_blank','width=400px;height=500px;toolbar=no;menubar=no;') } else { alert('用戶取消操作') } }