就算輸入百度的網(wǎng)址都是打開慕課網(wǎng),按取消也一樣會打開
<!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 A = confirm("是否打開新窗口?"); // 新窗口打開時彈出確認框,是否打開
? ? if(A==true)
? ? { ? var B = prompt("請輸入要打開的網(wǎng)址","http://idcbgp.cn/");// 通過輸入對話框,確定打開的網(wǎng)址,默認為 http://idcbgp.cn/
? ? ? ? window.open('B','_blank','width=400,height=500,menubar=no,toolbar=no'); ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? }
? ? else
? ? {
? ? ? ? }
? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2016-03-26
if下面那一行中的網(wǎng)址的http后面的 “:”注意要在英文輸入法狀態(tài)下輸入;
window.open() 中 “B”不需要引號;
剛剛試過,修改這兩點后,應該就OK了
2016-03-25
你把你的 代碼發(fā)出來呀