为什么在prompt窗口点了取消还是会打开新窗口的
function openWindow(){
var clickConfirm = confirm("是否打开网址输入框?");
if (clickConfirm == true){
var link = prompt("Please input the website address:","https://qq.com");
window.open(link,'_blank','width=500,height=600');
}
else {
alert("helloworld");
}
}我想实现点击确认打开新窗口,点击取消弹alert,但是好像不行。
另外我想尝试:
1、点击按钮先弹prompt窗口;点击确认再弹出confirm窗口;点击取消弹alert
2、弹出confirm窗口,点击确认打开新网页窗口,点击取消弹alert
试了很多个方式,但是都会提示else错误等等,无法正常实现我需要的功能。比如如下代码:
function openWindow(){
var link = prompt("Please input the website address:","https://qq.com");
if (prompt == true){
var clickConfirm = confirm("是否打开网址输入框?");
if (clickConfirm == true){
window.open(link,'_blank','width=500,height=600');
}
else {
alert("helloworld");
}
}
else {
alert("helloworld");
}
}请大家指点一下,谢谢