如何實現(xiàn)新窗口中彈出網(wǎng)頁內(nèi)容是在prompt里面輸入的網(wǎng)址? 不能直接用message放在windows.open里面?
<!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=prompt("請輸入對應(yīng)網(wǎng)址", "");
? if (message==false)
? { alert("wrong address");
? }
? else
? ? ? { rec(); }
? }
? function rec()
? {
? var a=confirm("是否打開網(wǎng)頁?");
? ?if (a==true)
? ?{ window.open('message','_blank','width=600,height=400,menubar=no,toolbar=no, status=no,scrollbars=yes'); }
? ?else { alert("您已取消進(jìn)入")}
? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2016-09-21
<!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=prompt("請輸入對應(yīng)網(wǎng)址", "");
? if (message==false)
? { alert("wrong address");
? }
? else
? ? ? { rec(message); }
? }
? function rec(net)
? {
? var a=confirm("是否打開網(wǎng)頁?");
? ?if (a==true)
? ?{ window.open(net,'_blank','width=600,height=400,menubar=no,toolbar=no, status=no,scrollbars=yes'); }
? ?else { alert("您已取消進(jìn)入")}
? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2016-09-21
message沒有傳過去。window.open 這里的message,你使用了單引號,代表的是一個字符串了。要用變量,就要去掉引號??梢愿某?/p>
else{?
rec(message);
}
?window.open(message,'_blank','width=600,height=400,menubar=no,toolbar=no, status=no,scrollbars=yes');?
2016-09-21
var message=prompt("請輸入對應(yīng)網(wǎng)址", "");
message會被賦值為輸入的網(wǎng)址,例如你輸入的是“http://idcbgp.cn/”;
message放在window.open里如下所示:
window.open(message,"_blank","width=600,height=400,menubar=no,toolbar=no, status=no,scrollbars=yes");