javascript - chrome 沒有showModalDialog方法怎么辦
問題描述
在訪問一些路由器設(shè)置頁面的時候,由于比較老,chrome竟然無法正常彈出設(shè)置窗口,console里報錯:showModalDialog方法不存在
問題解答
回答1:直接把對應(yīng)的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>
相關(guān)文章:
1. html5 - ElementUI table中el-table-column怎么設(shè)置百分比顯示。2. python - 使用readlines()方法讀取文件內(nèi)容后,再用for循環(huán)遍歷文件與變量匹配時出現(xiàn)疑難?3. 對mysql某個字段監(jiān)控的功能4. css3 - less或者scss 顏色計算的知識應(yīng)該怎么學(xué)?或者在哪里學(xué)?5. 注冊賬戶文字不能左右分離6. javascript - table列過多,有什么插件可以提供列排序和選擇顯示列的功能7. css - 網(wǎng)頁div區(qū)塊 像蘋果一樣可左右滑動 手機與電腦8. javascript - 數(shù)組的過濾和渲染9. html - vue項目中用到了elementUI問題10. JavaScript事件
