解決方案JavaScript編程練習(xí)
function openWindow(){ var mymessage=confirm("確定打開新的窗口嗎?") ; if(mymessage==true)// 新窗口打開時(shí)彈出確認(rèn)框,是否打開 { ?window.open('http://idcbgp.cn','width=400,height=500,menubar=no,toolbar=no')// 通過輸入對(duì)話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/ ? ?}//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。 ? ?else ? ?{; ? ?} ?}
2016-04-17
function openWindow() {
? ? ? ? var open = confirm("窗口是否打開?");
? ? ? ? var url = "http://idcbgp.cn/";
? ? ? ? if(open == true){
? ? ? ? ? ? confirm("打開網(wǎng)址"+ url);
? ? ? ? ? ? window.open("url","_blank","width=400, height=500, menubar=no, toolbar=no")
? ? ? ? }
2016-04-17
mymessage是確認(rèn)框的返回值,所以這里是字符串,所以不會(huì)與true相等,所以也就不會(huì)進(jìn)入if分支,從而就算點(diǎn)了確定也不會(huì)打開網(wǎng)頁,只要將判斷條件直接寫成if(mymessage)即可