window.showModalDialog刷新父窗口和本窗口的方法及注意:
 
一.刷新父窗口的方法:
   A.使用window.returnValue給父窗口傳值,然后根據(jù)值判斷是否刷新。

      在window.showModalDialog窗口頁面中用window.returnValue方式設(shè)置返回值;
      比如:window.returnValue='refresh';
   
   B。在寫window.showModalDialog彈出窗口函數(shù)時,定義個變量,然后根據(jù)變量值進行操作父窗口的操作;
   例如:var winPar=window.showModalDialog(urls,'ERPWINDOWS','dialogWidth='+widths+'px;dialogHeight='+heigths+'px;status=no;center=yes;scroll=no');
  if(winPar == "refresh")
       window.location.reload();//當(dāng)window.showModalDialog窗口關(guān)閉時執(zhí)行
         winPar為A步驟給showModalDialog窗口設(shè)置的返回值

  總結(jié):由于window.showModalDialog函數(shù)打開一個IE的模式窗口(就是打開后不能操作父窗口,只能等模式窗口關(guān)閉時才能操作),
    
        所以想要刷新父窗口只能在模式窗口關(guān)閉后執(zhí)行。用window.returnValue可以向父窗口傳值,這樣一來可以用從模式窗口向父窗口傳遞值,
 
 然后根據(jù)值判斷操作父窗口的方式來刷新。這樣在任何關(guān)閉了模式窗口后父窗口都會自動刷新.

二.刷新模式本窗口
   showModalDialog窗口與window.open打開的窗口刷新本窗口時不同,showModalDialo窗口也不能用F5刷新,也沒有右鍵操作
   A. 在模式窗口頁面中加入:     
      <base target="_self"> //在html和body之間
      <a id="reload" href="本頁面url" style="display:none"></a>

   B. 在需要執(zhí)行刷新操作的地方執(zhí)行以下js:
        reload.click();//reload為A中隱藏a標(biāo)簽的id,當(dāng)然可以換成其它名稱


三。注意事項

    在點擊window.showModalDialog窗口的鏈接的時候會打開新窗口,想要阻止打開新窗口,需要在窗口頁面中的html和body之間
    加入: <base target="_self" />即可