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. sass - gem install compass 使用淘寶 Ruby 安裝失敗,出現 4042. javascript - js 對中文進行MD5加密和python結果不一樣。3. mysql里的大表用mycat做水平拆分,是不是要先手動分好,再配置mycat4. window下mysql中文亂碼怎么解決??5. 為啥不用HBuilder?6. python - (初學者)代碼運行不起來,求指導,謝謝!7. javascript - h5上的手機號默認沒有識別8. python - 獲取到的數據生成新的mysql表9. python的文件讀寫問題?10. 為什么python中實例檢查推薦使用isinstance而不是type?
