新窗口打開時URL地址用變量保存,打開后網(wǎng)頁后總是會帶上/code/變量名,導(dǎo)致頁面無法顯示
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>? ?
? <script type="text/javascript">??
? ??
? ? // 新窗口打開時彈出確認框,是否打開
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? function openWindow(){
? ? ? ? var mycfmtxt="是否打開新窗口";
? ? ? ? var mycfm=confirm(mycfmtxt);
? ? ? ? if(mycfm==true){
? ? ? ? ? ? var mc='http://idcbgp.cn/';
? ? ? ? ? ? var myprompt=prompt("請確認是否打開慕課網(wǎng)",mc);
? ? ? ? ? ? if(myprompt!=null){
? ? ? ? ? ? ? ? window.open('myprompt','_blank','width=600,height=400,top=100,left=0,menubar=no,toolbar=no,status=no,scrollbars=no')
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2020-07-05
不要復(fù)制那個網(wǎng)址,因為注釋里給的是中文輸入法的:,不識別,你修改冒號,就可以了
2020-06-22
網(wǎng)址要用“”號框起來
2020-06-14
myprompt去掉單引號就可以正常顯示了