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. 为什么span的color非要内联样式才起作用?2. javascript - swiper.js嵌套了swiper 初始设置不能向下一个滑动 结束后重新初始3. python - Django ManyToManyField 字段数据在 admin后台 显示不正确,这是怎么回事?4. docker - 如何修改运行中容器的配置5. python - 如何修改twisted自带的日志输出格式?6. 求救一下,用新版的phpstudy,数据库过段时间会消失是什么情况?7. 请问一下各位老鸟 我一直在学习独孤九贱 现在是在tp5 今天发现 这个系列视频没有实战8. 在cmd下进入mysql数据库,可以输入中文,但是查看表信息,不显示中文,是怎么回事,怎新手,请老师9. github - 求助大神啊,win10 git clone error,折腾了几天都不行,以前原本好好的,突然就这样了10. 高并发写入和更新mysql

网公网安备