window.open()參數(shù)格式問(wèn)題和打開(kāi)新網(wǎng)址無(wú)法鏈接問(wèn)
<!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 url=prompt('打開(kāi)新窗口','http://yifanck.cn/');
? ? if(url!=null)
? ? // 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
{window.open(url,'-blank','width=400px,heigh=500px,menubar=no,toolbar=no')}
? ? // 通過(guò)輸入對(duì)話框,確定打開(kāi)的網(wǎng)址,默認(rèn)為 http://yifanck.cn/
? ? //打開(kāi)的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄。
? ??
? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
//上面是我的源代碼
問(wèn)題1:window.open(url,'-blank','width=400px,heigh=500px,menubar=no,toolbar=no'),這里的url要不要加引號(hào),而且參數(shù)字符串里面不打是不是默認(rèn)為0或no的?
問(wèn)題2:實(shí)際也是因?yàn)檫@個(gè)問(wèn)題才導(dǎo)致無(wú)法測(cè)試問(wèn)題1.。。。
上面的代碼打開(kāi)的網(wǎng)站無(wú)法鏈接(我用360打開(kāi)顯示網(wǎng)頁(yè)走丟了),把url改成'www.baidu.com'都不行
2016-11-13
<!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 xin=confirm("是否打開(kāi)?");
? ? ? ? if(xin==true){
? ? // 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
? ? ? ? ? ? var p=prompt("網(wǎng)址是:","http://yifanck.cn/");
? ? // 通過(guò)輸入對(duì)話框,確定打開(kāi)的網(wǎng)址,默認(rèn)為 http://yifanck.cn/
? ? ? ? window.open('p','_blank','width=400,height=500,menubar=no,toolbar=no')}
? ? //打開(kāi)的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄。
? ??
? ? }?
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2016-11-13
都要加引號(hào),每次參數(shù)也要分別加引號(hào)