覺得代碼沒錯啊,可是運行不了,求解答
<!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 mysrt=confirm("是否打開網頁");
? ? if (mysrt==true)
? ? {
? ? ? ? var my=prompt("請輸入網址","http://www.xianlaiwan.cn/");
? ? ? ? if(my !=null){
? ? ? ? ? ? window.open(my,'http://www.xianlaiwan.cn','_blank','width=400px,height=500px,menubar=no,toolbar=no')
? ? ? ? ? ? else{alert("再見");
? ? ? ? }
? ? }
? ? else{
? ? alert("再見!");
? ? }
? ? }
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openwindow()" />?
?</body>
</html>
2016-11-28
//以上代碼已經修改完畢,測試成功
代碼我看了一會,原來是ifelse{}符號不匹配,下次遇到這種問題,試試用chrome的檢查工具查看問題,剛剛,一下就找到問題所在了
2016-11-28
<!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 mysrt = confirm("是否打開網頁");
? ? ??
? ? if (mysrt==true)
? ? {
? ? ? ? var my=prompt("請輸入網址:","http://www.xianlaiwan.cn/"); ?
? ? ? ? if(my != null){
? ? ? ? ? ? window.open('http://www.xianlaiwan.cn','_blank','width=400px,height=500px,menubar=no,toolbar=no');
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? alert("再見!");
? ? ? ? ? ? }
? ? }else{
? ? ? ? alert("再見!");
? ? ? ? }
? ? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
測試通過了!一些標點的問題
2016-11-28
if ..else.函數那里寫的有問題,第二個if和else之間少了一個大括號
2016-11-28