第一个问题我自己解决了,是我的错误。在1.htm里面应该使用变量把window对象传递到模态对话框中,这样对话框才能操纵父窗口。
我要的效果是模态对话框操作后关闭自动刷新父窗口,下面是代码:
1.html
var me;
me = window;
window.showModelDialog('2.htm',me,"dialogHeigh:200;dialogWidth:200");2.htm
if(dialogArguments != null)
{
    dialogArguments.location.reload(true);
    window.close();
}
这样,对话框提交后可以自动刷新父窗口,用不着使用window.open()打开新窗口后使用
window.opener.location.reload(true);
刷新父窗口了。

解决方案 »

  1.   

    3.
    window.Form1.msg.innerText = 'aa';
    =>
    document.all.msg.innerText = 'aa';你的 msg 是什么东西, 看你用 msg.innerText 那么 msg 肯定就不是表单元素了, 那你的调用方法是错的
      

  2.   

    1.2.
    你的 2.htm 做成正规的 HTML 网页, 而不只放几句JS脚本!!!!
      

  3.   

    <script>
    window.showModelessDialog('2.htm',window,"dialogHeigh:200;dialogWidth:200");
    </script>这条语句绝对能执行,
    你那个showModelDialog拼错了罢了。
      

  4.   

    1.htm
    <script>
    if(document.cookie=="")
    {
    document.cookie=0;
    }
    else
    {
    var cookie = document.cookie;
    cookie = parseInt(cookie);
    n = cookie + 1;
    document.write("第<font color='red'>"+n+"</font>次刷新");
    document.cookie = n;
    }
    function show()
    {
    window.showModelessDialog('2.htm',window,"dialogHeigh:200;dialogWidth:200");
    }
    </script>
    <button onclick="show()">show</button>
    2.htm
    <script>
    var arg = dialogArguments;
    function test()
    {
    if(arg != null)
    {
        dialogArguments.location.reload(true);
        window.onunload = new Function("");
        window.close();
    }
    }
    window.onunload = test
    </script>
    <button onclick=test()>关闭并且刷新父窗口</button>
      

  5.   

    To aotianlong(初中没毕业):
    老大,你看清楚,我用的是模态对话框,不是非模态对话框,如果我用你的window.showModelessDialog(),那么不如直接用window.open(),什么都搞定了。
      

  6.   

    to zhaiyf(zhaiyf):
    模态对话框就是像你使用一些windows应用程序出现的警告对话框和word的打印对话框一样,你打开了这样的对话框,必须在这个窗口上操作,直到你关闭这个窗口,你才能操作其他窗口,否则不允许你操作其他窗口。这就是模态对跨框。
      

  7.   

    to :hrong(黄蓉):
    你说的是对的,我加的是<div>元素,不是表单元素,所以不可用,我使用
    window.document.getElementById("msg").innerText = 'aa';
    就行了。
    另外,我写的2.htm是简化成这个样子的,实际上2.htm是个addCustom.aspx的asp.net页面,有很多代码。