前台技術--window.showModalDialog帶來的瀏覽器安全色問題

來源:互聯網
上載者:User

雙擊域的實現:http://blog.csdn.net/gaopeng0071/article/details/21179619,

繼此篇博文,講述的雙擊域實現,在後續發現使用window.showModalDialog模態框存在瀏覽器安全色性問題。

使用chrome時,會出現模態框的返回值無法返回到父頁面,使用此種方式: window.returnValue

  • 摘自:http://blog.csdn.net/luckzhang_la/article/details/17262421

這個方法存在瀏覽器安全色問題。採用ie核心的瀏覽器支援該方式,但採用Google核心的瀏覽器(如:Chrome)不支援。

不支援表現在window.showModalDialog()方法,採用Google核心的瀏覽器並不是開啟一個模式彈出框而是window.open()。這樣在彈出框裡設定返回值window.returnValue="返回值";在父表單擷取時var  vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])發現vReturnValue為undefined。


解決方案如下:

父頁面:

詳見其中第4行判斷與第7行判斷代碼。

function ondbGuanLianADId(){adId = window.showModalDialog('getAdForMac.action', null ,'dialogHeight=500px; dialogWidth=420px;');var strs = adId;    if(strs==undefined){    strs=window.returnValue;    }if(strs != undefined){document.getElementById("guanLianADId").value = strs.split(":")[0];document.getElementById("guanLianADName").value = strs.split(":")[1];}}
子頁面:

function test(){// 解決IE與chrome瀏覽器版本差異問題 if (window.opener != undefined) {         //for chrome           window.opener.returnValue = document.getElementById("name1").value;     }     else {         window.returnValue = document.getElementById("name1").value;     }window.close();}


參考資源:http://blog.csdn.net/luckzhang_la/article/details/17262421


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.