zoukankan      html  css  js  c++  java
  • 谷歌不兼容showModalDialog()方法出现对话窗口解决方法

          javascript中showModalDialog()方法在IE,火狐,百度,360等浏览器可以使用,但是在谷歌浏览器下去没有任何反应,现在我给大家一种方法,当然这个方法是我在网上找的,调试可以使用。

    <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事件进行调用方法就行

  • 相关阅读:
    DRF初始准备
    树与二叉树知识点总结(一)
    html牛刀小试
    Python算法黑科技collection模块
    栈和队列知识点总结
    python结束程序的三种技巧
    爬虫01
    Django大结局
    Django报错 Forbidden (CSRF token missing or incorrect.): 解决方法
    Django进阶
  • 原文地址:https://www.cnblogs.com/fengjiqiang/p/5190377.html
Copyright © 2011-2022 走看看