新打開的窗口的url一直報404
<!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 makesure=confirm("OPEN?")
? ? ? ? if(makesure==true){
? ? ? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? ? ? ? ? var open=prompt("URL","www.baidu.com")
? ? ? ? ? ? ? ? ? ??
? ? ? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? ? ? ? ? window.open("www.baidu.com","_blank","width=400,height=500,meunbar=no,toolbar=no")
? ? ? ? }
? ? ? ? else{
? ? ? ? ? ?document.write("close")?
? ? ? ? }
? ? }
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
2018-05-03
url?加上http://
不然它默認在http://www.xianlaiwan.cn/code/?url下加上你的地址
跟文件的路徑是一個道理,不加根目錄“/”表示的是相對地址,加上根目錄才是絕對地址。
對應過來根目錄就相當于url的協議名“http://’
2018-05-03
window.open方法的第一個參數應該是單引號引用