如何實現window .open打開prompt中的值
<!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 message=confirm("是否要打開新窗口?")
? ? ?if(message==true)
? ? ?{
? ? ? var href=prompt("請輸入網址:");
? ? ? if(href!=null)
? ? ? ?{?
? ? ? ? window.open(href,'_blank','width=400,height=500,menubar=no,toolbar=no')
? ? ? ?}
? ? ? ?else
? ? ? ?{window.open('http://www.xianlaiwan.cn','_blank','width=400,height=500,menubar=no,toolbar=no')
? }
? ? ?}
? ? ?else
? ? ?{
? ? ?document.write("你取消了操作!") ? ?
? ? ?}
? ? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
先編輯如上,可以獲得值,但無法打開prompt中的網址。請大蝦……
2015-02-09
可以打開啊,不過你在prompt中輸入網址的時候,需要帶http://這個前綴
2016-04-06
怎么懂了,我也在這個上面遇到難度了,怎么window.open()取得prompt輸入的網址
2015-02-13
下次研究下自動填入http://
2015-02-11
也就是我之前問的“如何取出prompt對話框中輸入的值?”,你的回答我試了但不行
2015-02-11
我是希望打開客戶端輸入的值,不是服務器端本來就有的值。