javascript - chrome 沒有showModalDialog方法怎么辦
問題描述
在訪問一些路由器設置頁面的時候,由于比較老,chrome竟然無法正常彈出設置窗口,console里報錯:showModalDialog方法不存在
問題解答
回答1:直接把對應的showModalDialog方法改成open就可以了
另stackoverflow上的代碼,但是有時候不起作用
<script type='text/javascript'> // fix for deprecated method in Chrome 37 if (!window.showModalDialog) { window.showModalDialog = function (arg1, arg2, arg3) {var w;var h;var resizable = 'no';var scroll = 'no';var status = 'no';// get the modal specsvar mdattrs = arg3.split(';');for (i = 0; i < mdattrs.length; i++) { var mdattr = mdattrs[i].split(':'); var n = mdattr[0]; var v = mdattr[1]; if (n) { n = n.trim().toLowerCase(); } if (v) { v = v.trim().toLowerCase(); } if (n == 'dialogheight') { h = v.replace('px', ''); } else if (n == 'dialogwidth') { w = v.replace('px', ''); } else if (n == 'resizable') { resizable = v; } else if (n == 'scroll') { scroll = v; } else if (n == 'status') { status = v; }}var left = window.screenX + (window.outerWidth / 2) - (w / 2);var top = window.screenY + (window.outerHeight / 2) - (h / 2);var targetWin = window.open(arg1, arg1, ’toolbar=no, location=no, directories=no, status=’ + status + ’, menubar=no, scrollbars=’ + scroll + ’, resizable=’ + resizable + ’, copyhistory=no, width=’ + w + ’, height=’ + h + ’, top=’ + top + ’, left=’ + left);targetWin.focus(); }; }</script>
相關文章:
1. sql語句 - 如何在mysql中批量添加用戶?2. shell - Update query wrong in MySQL3. javascript - mysql插入數據時怎樣避免與庫中的數據重復?4. php - 數據庫表如果是null怎么替換為其他字段的值5. 事務 - mysql共享鎖lock in share mode的實際使用場景6. 怎么php怎么通過數組顯示sql查詢結果呢,查詢結果有多條,如圖。7. mysql - JAVA怎么實現一個DAO同時實現查詢兩個實體類的結果集8. SQLAlchemy 訪問Mysql數據庫彈出Warning,VARIABLE_VALUE,如何解決?9. mysql - 數據庫建字段,默認值空和empty string有什么區別 11010. mysql建表報錯,查手冊看不懂,求解?
