<!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?ccc=confirm("你想要打開新窗口嗎?");//?新窗口打開時彈出確認框,是否打開
????if(ccc==true)
????{
???????var?aaa=prompt("請輸入網(wǎng)址:""http://idcbgp.cn/")
???????if(aaa!=null){
????????alert("歡迎進入");
????????window.open("http://idcbgp.cn/","_blank""width=400,height=500,menubar=no,toolbar=no");??
???????}
???????else{alert("請輸入地址");}
????}
????else{
?????????document.write("下次再見");????
????}???
????}//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
???
??</script>?
?</head>?
?<body>?
??<input?type="button"?value="新窗口打開網(wǎng)站"?onclick="openWindow()"?/>?
?</body>
</html>
2017-08-01
你的邏輯沒有問題,但是太馬虎了,你嵌套的if語句缺少閉合符號},函數(shù)名openWindow前后不一樣,還有一個?var?aaa=prompt("請輸入網(wǎng)址:""http://idcbgp.cn/")兩個屬性間缺少逗號,另外不知道你的符號是否都是英文狀態(tài),最好自己調(diào)一調(diào),我前幾天因為缺少一個分號調(diào)了半天,希望共勉。
2017-08-01
<!DOCTYPE HTML>
<html>
?<head>
? ?
? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ?
? <title> new document </title>?
? <script type="text/javascript">
? function Wopen(){
?
? ? ?window.open('http://idcbgp.cn','_blank','width=300,height=200,menubar=no,toolbar=no, status=no,scrollbars=yes ');
? }
?
? function winopen(){
? ? ? // 新窗口打開時彈出確認框,是否打開
? ? var myopen = confirm("是否打開新窗口");
// var shu = prompt('輸入你想要打開的網(wǎng)址'); ? prompt這是個對話框 ?不能打開外部鏈接
? ? if(myopen==true){
? ?
? ? ? ? window.open('http://idcbgp.cn', '_top ' , ' width=400 , height=500 , menubar=no ,toolbar=no , status=no ,scrollbars=yes ');
? ? }
? ? else{
? ? ? ? myopen.close();
? ? }
?}
? ?
? </script>?
?</head>?
?<body>?
?<input name="button" type="button" ?onClick="winopen()" value="新窗口打開網(wǎng)站"/>?
?<input name="button" type="button" onClick="Wopen()" value="點擊我,打開新窗口!" / >
?</body>
</html>
?我也是剛寫過類似的 就是prompt的問題 ? 我給他注了
2017-08-01
prompt 是個對話框,好像不能輸入地址或者路徑
2017-08-01
有幾個錯誤,meta里charset=UTF-8,兼容中文;script里的函數(shù)名openWindow的W應該是大寫;prompt里面的兩個輸入之間用逗號隔開;window.open的窗口名稱與參數(shù)字符串之間用逗號隔開。
代碼如下:
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> ??
? <script type="text/javascript"> ?
? ? function openWindow(){
? ? var ccc=confirm("你想要打開新窗口嗎?");// 新窗口打開時彈出確認框,是否打開
? ? if(ccc==true)
? ? {
? ? ? ?var aaa=prompt("請輸入網(wǎng)址:","http://idcbgp.cn/")
? ? ? ?if(aaa!=null){
? ? ? ? alert("歡迎進入");
? ? ? ? window.open("http://idcbgp.cn/","_blank","width=400,height=500,menubar=no,toolbar=no"); ?
? ? ? ?}
? ? ? ?else{alert("請輸入地址");}
? ? }
? ? else{
? ? ? ? ?document.write("下次再見"); ? ?
? ? } ??
? ? }//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? </script>?
?</head>?
?<body>?
? ? ? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2017-08-01
onclick="openWindow()" 關(guān)聯(lián)的是openWindow這個名字,你命名沒一致,換下名字openWindow為ccc