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. 模板渲染时报错,怎么处理2. node.js - 使用mongoose的cursor的问题3. javascript - nodemailer连接超时,怎么解决?4. Java。比较字符串时忽略重音5. mysql - Access denied for user ’ODBC’@’localhost’ (using password: NO)6. 请问一下,图片上传成功,但是后台对应文件夹里面却没有图片,这是什么原因?(已部署到服务器)7. 在别的电脑使用JDBC连接其他电脑上安装的mysql数据库8. PHP中的$this代表当前的类还是方法?9. mysql - 订单表,我把它分成好几个,我要查询订单,怎么用一条sql语句高效查询10. php - MySQL数据库设计,获取点赞的人数

网公网安备