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. angular.js - 百度爬虫如何处理“#”符号?2. nosql - mongodb 多组数据不固定字段查询问题 [百度党请绕道]3. javascript - 跨域,我的jsonp方式对不,为什么一直报错啊4. css - angular前端如何让ng-repeat的内容并排一行,跑起来呢?5. css3怎么能做到弧形的运动轨迹6. angular.js - 调后台接口 返回数据同步到 scope 上的 service 怎么写?~7. 如何解决docker宿主机无法访问容器中的服务?8. javascript - 微信jssdk ios下自定义onMenuShareAppMessage 分享失效,Android分享成功9. 老师百度网盘分享一下WampServer的包啊,我们下载几kb要下载一天的.10. vue.js - linux下怎么使用vue-cli的vue命令
