百度空间 | 百度首页 
 
查看文章
 
用window.open()代替window.showModalDialog()
2008-08-27 17:36

来源:JavaEye    作者:ddh9504

模式窗口太过于局限性,所以我研究了一个完全可以用 window.open()代替window.showModalDialog()的方法,其资料贴在了下面:

有两个页面,一个是调用页面---main.html,一个是被调用页面---modalWindow.html

HTML语言: main.html
<html>
<head>
<script type="text/javascript">

    newWin = null;
   
    function doOpen() {
        newWin = window.open('modalWindow.html','newWin','height=200,width=400,top=200,left=200,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no');
    }
   
    window.onfocus = function() {
        if(newWin) {
            if(!newWin.closed) {
                newWin.focus();
            }
        }
    }
   
    window.document.onfocus = function() {
        if(newWin) {
            if(!newWin.closed) {
                newWin.focus();
            }
        }
    }
   
    window.document.onclick = function() {
        if(newWin) {
            if(!newWin.closed) {
                newWin.focus();
            }
        }
    }
   
    window.document.ondblclick = function() {
        if(newWin) {
            if(!newWin.closed) {
                newWin.focus();
            }
        }
    }
   
</script>

<title>main</title>
</head>
<body>
    <input type="button" value="Show me" onclick="doOpen();">
</body>
</html>

*************************************************************************************************************

*************************************************************************************************************

HTML语言: modalWindow.html

<html>
<head>
    <title>modalWindow</title>
</head>
<body>
    sub window!!!!
</body>
</html>

在这个页面 modalWindow.html 中的方法可以调用父窗口的方法

其用法是 opener.functionName(param);

引文来源  真正的用window.open()代替window.showModalDialog() - 慧都控件网


类别:javascript && web | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu