變量被賦值了一個網址如何調用這個網址?
<!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 a=confirm("確定打開嗎?");
? ? ? ? ? ? if(a==true){
? ? ? ? ? ? ? var b=prompt("請輸入您的網址!") ?
if(b!==null){
?window.open("b","_blank","top=200,left=200,width=600,height=400,menubar=no,toolbar=no")
}else{}
? ? ? ? ? ? }else{}
? ? ? ? }
? ??
? </script>?
?</head>?
?<body>?
? ? ? <input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
變量b已經被賦值了。比如我們輸入的是一個網址。這個時候b就被賦值了一個網址。如何使用b的值呢?
2015-08-19
if(b!==null) ?為什么這樣寫 ?用ture不行嗎?
2015-08-14
變量名是不需要加引號的。
這里最好給個默認網站吧
修改后的代碼,你看看