有沒有更好的方法?
function openWindow(){
? ? ? ? var a = confirm("確定打開新窗口?");//新窗口打開時彈出確認框,是否打開
? ? ? ? if(a==true){?
? ? ? ? ? ? var youurl = prompt("請輸入需要打開的網(wǎng)址!","http://");
? ? ? ? ? ? if(youurl!=null){
? ? ? ? ? ? ? ? //通過輸入對話框,打開輸入的網(wǎng)址
? ? ? ? ? ? ? ? window.open( youurl ,'_blank','width=400,height=500,menubar=yes,toolbar=yes');
? ? ? ? ? ? }
? ? ? ? ? ? else{
? ? ? ? ? ? ? ? //如果不輸入則默認打開http://idcbgp.cn/
? ? ? ? ? ? ? ? window.open('http://idcbgp.cn','_blank','width=400,height=500,menubar=yes,toolbar=yes');
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? else{
? ? ? ? ? ? document.write("打開失??!");
? ? ? ? }
? ? };
2018-08-30
樓上老哥?if(opw!=null){? ?為啥要打個!呢?沒有這個嘆號好像還不好使,是因為啥呢
2018-08-22
? // 新窗口打開時彈出確認框,是否打開
??? function? openWindow(){
?????? var? cmopen= confirm("是否打開新窗口?");
????? ?
// 通過輸入對話框,確定打開的網(wǎng)址,默認為 http://idcbgp.cn/????? ?
?????? if(cmopen==true){
?????????? var opw= prompt("請輸入正確網(wǎng)址https不能為空","https://www.baidu.com");
?????? }
????? ?
//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄
????? if(opw!=null){
????????? window.open(opw,"_blank","width=400,height=500,menubar=no,toolbar=no");
????? }
??? }
2018-08-22
直接把網(wǎng)址換成http://idcbgp.cn就可以了,如下
var youurl = prompt("請輸入需要打開的網(wǎng)址!","http://idcbgp.cn");
后面的判斷youurl是否為空就可去掉