window.open與showModalDialog

open和showModalDialog都是打開一個新窗口,但是showModalDialog會將子窗口固定在父窗口前面,不關閉子窗口無法使用父窗口。

 

window.open("view/excel_pattern.jsp",null,

"resizable=no,toolbar=no,menubar=no,height="+height+",width="+width+",top="+top+",left="+left);

子窗口調用父窗口js:

opener.refresh();//refresh()是父窗口寫的js function

 
 window.showModalDialog("view/excel_pattern.jsp",window,

"dialogHeight:"+height+"px;dialogWidth:"+width+"px;dialogTop:"+top+"px;dialogLeft:"+left+"px");


showModalDialog()第二個參數可爲"",但是如果要在子窗口中調用父窗口js,就一定要寫成window。

子窗口:

var par = window.dialogArguments;
par.import(t);//import()是父窗口寫的js function

 

 

注:opener是window.open時使用;

      parent是iframe的src頁面使用的,概念不同

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章