谷歌showModalDialog()方法不兼容出现对话窗口的解决办法
作者:bea
showModalDialog,在测试中,IE,Firefox中正常运行,但是在google中,点击后没什么反应,在网上看了一下,谷歌浏览器不支持showModalDialog模态对话框和无法返回returnValue,得到了一个解决办法 <script type="text/javascript">//开启模式窗口function showMyModal() {var url = "SelectUser.aspx";//传入参数示例var modalRet
showModalDialog,在测试中,IE,Firefox中正常运行,但是在google中,点击后没什么反应,在网上看了一下,谷歌浏览器不支持showModalDialog模态对话框和无法返回returnValue,得到了一个解决办法
<script type="text/javascript">
//开启模式窗口
function showMyModal() {
var url = "SelectUser.aspx";
//传入参数示例
var modalReturnValue = myShowModalDialog(url, window, 300, 500);
//alert(modalReturnValue.name);
//窗口关闭后执行某些方法
//TODO sth
}
//弹出框google Chrome执行的是open
function myShowModalDialog(url, args, width, height) {
var tempReturnValue;
if (navigator.userAgent.indexOf("Chrome") > 0) {
var paramsChrome = 'height=' + height + ', width=' + width + ', top=' + (((window.screen.height - height) / 2) - 50) +
',left=' + ((window.screen.width - width) / 2) + ',toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no';
window.open(url, "newwindow", paramsChrome);
}
else {
var params = 'dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;status:no;dialogLeft:'
+ ((window.screen.width - width) / 2) + 'px;dialogTop:' + (((window.screen.height - height) / 2) - 50) + 'px;';
tempReturnValue = window.showModalDialog(url, args, params);
}
return tempReturnValue;
}
</script>
最后想要点击就可以出现对话框就行,只需要使用onclick事件进行调用方法就行
以上给大家介绍了谷歌showModalDialog()方法不兼容出现对话窗口的问题分析及解决办法,希望对大家有所帮助。
有用 | 无用
<script type="text/javascript">
//开启模式窗口
function showMyModal() {
var url = "SelectUser.aspx";
//传入参数示例
var modalReturnValue = myShowModalDialog(url, window, 300, 500);
//alert(modalReturnValue.name);
//窗口关闭后执行某些方法
//TODO sth
}
//弹出框google Chrome执行的是open
function myShowModalDialog(url, args, width, height) {
var tempReturnValue;
if (navigator.userAgent.indexOf("Chrome") > 0) {
var paramsChrome = 'height=' + height + ', width=' + width + ', top=' + (((window.screen.height - height) / 2) - 50) +
',left=' + ((window.screen.width - width) / 2) + ',toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no';
window.open(url, "newwindow", paramsChrome);
}
else {
var params = 'dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;status:no;dialogLeft:'
+ ((window.screen.width - width) / 2) + 'px;dialogTop:' + (((window.screen.height - height) / 2) - 50) + 'px;';
tempReturnValue = window.showModalDialog(url, args, params);
}
return tempReturnValue;
}
</script>
最后想要点击就可以出现对话框就行,只需要使用onclick事件进行调用方法就行
以上给大家介绍了谷歌showModalDialog()方法不兼容出现对话窗口的问题分析及解决办法,希望对大家有所帮助。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- Javascript中的Prototype到底是什么
- 剖析Node.js异步编程中的回调与代码设计模式
- 使用Node.js处理前端代码文件的编码问题
- 让图片跳跃起来 javascript图片轮播特效
- Node.js本地文件操作之文件拷贝与目录遍历的方法
- 详解Node.js包的工程目录与NPM包管理器的使用
- javascript每日必学之运算符
- 解析Node.js基于模块和包的代码部署方式
- javascript每日必学之基础入门
- 快速掌握Node.js环境的安装与运行方法
- js实现异步循环实现代码
- JavaScript实现跑马灯抽奖活动实例代码解析与优化(二)
- JavaScript实现跑马灯抽奖活动实例代码解析与优化(一)
- javascript HTML+CSS实现经典橙色导航菜单
- JavaScript中使用数组方法汇总
- jquery拖拽排序简单实现方法(效果增强版)
- jquery实现具有收缩功能的垂直导航菜单
- 学习使用AngularJS文件上传控件
- JS中call/apply、arguments、undefined/null方法详解