• 浏览器兼容:改写window.showModalDialog


    以前很多网页都使用如下脚本来打开对话框,这脚本只能在IE下使用,对于某些浏览器来说完全不兼容。
    var returnValue = window.showModalDialog(url,'',features);

    最近在浏览器兼容的工作,必须把这些不兼容的问题一一解决掉。针对此问题,修改如下:

    1、在父窗体的脚本:
     var winNew=null;

     function openNewWin(url) {
        if(winNew && winNew.open && !winNew.closed){
           winNew.focus();
           return false;
        }
        var myDate = new Date();
        var intWidth = 670;
        var intHeight = 500;
        var intX = (screen.availWidth - intWidth) / 2;
        var intY = (screen.availHeight - intHeight) / 2;

        var strFeatures = 'resizable=no,status=no,scrollbars=yes,model=yes,width=' + intWidth + ',height=' + intHeight + ',left=' + intX + ',top=' + intY;
       
    winNew = window.open(url, 'newWin', strFeatures);
       
    winNew.focus();
    }
    2、在弹出窗体的脚本:
       var winParent = window.opener;
       winParent.winNew = window;

      
       //如果要改变父窗体的元素值,可以通过如下脚本实现
       var winP = window.winParent.document;
       winP.getElementById('元素id').value = '.....';

  • 相关阅读:
    LeetCode91 Decode Ways
    LeetCode93 Restore IP Addresses
    LeetCode92 Reverse Linked List II
    LeetCode90 Subsets II
    LeetCode89 Gray Code
    最长公共子序列及其引申问题
    constexpr:编译期与运行期之间的神秘关键字
    I/O模型: 阻塞、非阻塞、I/O复用、同步、异步
    LeetCode86 Partition List
    maven 安装 过程
  • 原文地址:https://www.cnblogs.com/yumianhu/p/3710748.html
Copyright © 2020-2023  润新知