為什么是打開的http://www.xianlaiwan.cn/code/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 newWindow=confirm("是否打開網站?")
? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? if(newWindow==true){
? ? ? ? var http=prompt("請輸入網址","http:www.xianlaiwan.cn")
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? window.open(http,'_blank','width=400,height=500,menubar=no,toolbar=no') ? ?
? ? ? ? } ? ? ? ?
? ? } ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>?
2017-01-17
我也是 ?解決了么
2017-01-17
我開始也出現了這個問題 可能是JS的版本問題,但是解決方法如下
? function openWindow(){
? ? ? ? var url = confirm("是否打開新網頁");
? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? ? ?if (url == true){
? ? ? ? ? ?var url = prompt("請輸入要打開的網址:","www.xianlaiwan.cn") ;?
? ? ? ? ? ?document.write(win);
? var html = "http://"+win ;
? document.write(html);
? ? ? ? ? ? window.open(html,'_blank','width= 400 height= 500','menubar =no','toolbar=no')
? ? }
前面加上一個http://? 再創建一個新的var ?就可以改變新窗口的路徑
2017-01-06
據我實驗,貌似是這樣。prompt已經包括http告訴瀏覽器協議了,window.open后面如果再寫網址就重復了。
2017-01-06
? ? function openWindow(){
? ? ? ? var msg=confirm("open new website?")
? ? ? ? var newwind="http://www.xianlaiwan.cn/"
? ? ? ? if(msg==true){
? ? ? ? ? ? prompt("Key in the address: ", "www.xianlaiwan.cn/");
? ? ? ? ? ? window.open(newwind, "_blank", "width=400px, height=500px, menubar=no, toolbar=no");
? ? ? ? }
}
2017-01-05
<script type="text/javascript"> ?
? ?function openWindow(){
? ? var s=confirm("確認要打開新網站嗎?"); ??
? ? if(s){window.open('http://www.xianlaiwan.cn','_blank','width=400px,height=500px,menubar=no,toolbar=no')
? ?}? </script>
2017-01-03
地址寫錯了 。。。http://www.xianlaiwan.cn? ?你少“//”了