為什么我輸入其他網(wǎng)頁就跳轉(zhuǎn)到亂碼的網(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 ppt=prompt("請輸入目標網(wǎng)址:","http://idcbgp.cn")
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認為 http://idcbgp.cn/
if(ppt!=null){window.open(ppt,"_blank","width=400px,height=500px,menubar=no,toolbar=no");
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
if(ppt==""){alert("請輸入網(wǎng)址!")}
}
}
}
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
還有就是我想在if(ppt==""){alert("請輸入網(wǎng)址!")}這句實現(xiàn)可以在按確定以后自動打開prompt這個文本框
2015-12-12
?<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>?
charset=gbk" ? 改成 ? charset = 'utf-8'
2015-12-12
編碼問題~兩個頁面的編碼要保持一致,要么都gbk,要么都utf8哦~