谷歌showModalDialog()方法不兼容出現(xiàn)對話窗口的解決辦法
showModalDialog,在測試中,IE,F(xiàn)irefox中正常運行,但是在google中,點擊后沒什么反應,在網(wǎng)上看了一下,谷歌瀏覽器不支持showModalDialog模態(tài)對話框和無法返回returnValue,得到了一個解決辦法
<script type="text/javascript"> //開啟模式窗口 function showMyModal() { var url = "SelectUser.aspx"; //傳入?yún)?shù)示例 var modalReturnValue = myShowModalDialog(url, window, 300, 500); //alert(modalReturnValue.name); //窗口關閉后執(zhí)行某些方法 //TODO sth } //彈出框google Chrome執(zhí)行的是open function myShowModalDialog(url, args, width, height) { var tempReturnValue; if (navigator.userAgent.indexOf("Chrome") > 0) { var paramsChrome = 'height=' + height + ', width=' + width + ', top=' + (((window.screen.height - height) / 2) - 50) + ',left=' + ((window.screen.width - width) / 2) + ',toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no'; window.open(url, "newwindow", paramsChrome); } else { var params = 'dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;status:no;dialogLeft:' + ((window.screen.width - width) / 2) + 'px;dialogTop:' + (((window.screen.height - height) / 2) - 50) + 'px;'; tempReturnValue = window.showModalDialog(url, args, params); } return tempReturnValue; } </script>
最后想要點擊就可以出現(xiàn)對話框就行,只需要使用onclick事件進行調用方法就行
以上給大家介紹了谷歌showModalDialog()方法不兼容出現(xiàn)對話窗口的問題分析及解決辦法,希望對大家有所幫助。
- js模式化窗口問題![window.dialogArguments]
- window.dialogArguments 使用說明
- Chrome不支持showModalDialog模態(tài)對話框和無法返回returnValue問題的解決方法
- JS在Chrome瀏覽器中showModalDialog函數(shù)返回值為undefined的解決方法
- 谷歌瀏覽器不支持showModalDialog模態(tài)對話框的解決方法
- showModalDialog模態(tài)對話框的使用詳解以及瀏覽器兼容
- showModalDialog在谷歌瀏覽器下會返回Null的解決方法
- window.showModalDialog兩次加載問題清除緩存方法
- Chrome中模態(tài)對話框showModalDialog返回值問題的解決方法
相關文章
html的DOM中document對象images集合用法實例
這篇文章主要介紹了html的DOM中document對象images集合用法,實例分析了images集合的語法與使用技巧,需要的朋友可以參考下2015-01-01JS實現(xiàn)的5級聯(lián)動Select下拉選擇框實例
這篇文章主要介紹了JS實現(xiàn)的5級聯(lián)動Select下拉選擇框,涉及javascript數(shù)組調用及遍歷的相關技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-08-08JavaScript實現(xiàn)動態(tài)生成表格案例詳解
本文主要介紹了通過JavaScript實現(xiàn)一個動態(tài)添加表格的案例,當點擊添加按鈕時,可以彈出一個表單,然后將輸入的內容添加到表格中,也可以將表格中的整行內容清除。感興趣的可以學習一下2021-12-12JavaScript實現(xiàn)單擊網(wǎng)頁任意位置打開新窗口與關閉窗口的方法
這篇文章主要介紹了JavaScript實現(xiàn)單擊網(wǎng)頁任意位置打開新窗口與關閉窗口的方法,涉及javascript窗口的相關操作函數(shù)與使用技巧,需要的朋友可以參考下2017-09-09javascript的var與let,const之間的區(qū)別詳解
這篇文章主要為大家介紹了?javascript的var與let,const之間的區(qū)別,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助2021-12-12