為什么window.open里面網(wǎng)站 不能寫成’http://’+ad只能在外面在重新定義一個(gè)變量
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>? ?
? <script type="text/javascript">??
? ??
? ? // 新窗口打開時(shí)彈出確認(rèn)框,是否打開
? ? function openWindow(){
? ? ? ? var my=confirm("確認(rèn)打開新的網(wǎng)站")
? ? ? ? if(my==true){
? ? ? ? ?var? ad=prompt("請輸入網(wǎng)站")
? ? ? ? var ap= "http://"+ad
? ? ? ? ? ? if(ad!=null&&ad!=""){
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? window.open(ap,'_black','width=400,height=500,menubar=no,toolbar=no')
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? window.open('http://idcbgp.cn','_black','width=400,height=500,menubar=no,toolbar=no')
? ? ? ? ? ? }
? ? ? ? }else{
? ? ? ? }? ??
? ? };
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2019-02-06
可以寫,檢查一下你的代碼