求助 !最后打開的窗口一直打不開網頁
<!DOCTYPE?html>
<html>
<head>
????<title>?new?document?</title>
????<meta?http-equiv="Content-Type"?content="text/html;?charset=gbk"?/>
????<script?type="text/javascript">
????????var?tip?=?confirm("在?打開網頁?");
????????if?(tip?==?true)?{
????????????var?address?=?prompt("Please?input?web?address",?"http://www.xianlaiwan.cn/");
????????????function?openWindow()?{
????????????????window.open('address',?'_blank',?'width=400px',?'height=500px');
????????????}
????????}
????????else?{?}
????</script>
</head>
<body>
????<input?type="button"?value="新窗口打開網站"?onclick="openWindow()"?/>
</body>
</html>
2020-01-07
好像邏輯就錯了吧,函數openWindow()
應該把'var?tip?=?confirm("在?打開網頁?");'包住吧;另外,"http://www.xianlaiwan.cn/"里的“:”為中文狀態下的,改為英文狀態下的:
<!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?tip?=?confirm("在?打開網頁?");
????????if?(tip?==?true)?{
????????????var?address?=?prompt("Please?input?web?address",?"http://www.xianlaiwan.cn/");
??????????? //function?openWindow()?{
????????????????window.open('address',?'_blank',?'width=400px',?'height=500px');
?????????? // }
????????}
????????else?{?}
?? }
????</script>
</head>
<body>
????<input?type="button"?value="新窗口打開網站"?onclick="openWindow()"?/>
</body>
</html>
2020-01-07
最后打開網址前應在加個判斷,否則點取消也會打開個空網址