我写了一个action,返回类型是生成报表的文件流,在前台页面想弹出保存报表的对话框,就在页面用了window.open(url),其中url是action的路径,这些功能没问题,可以实现。
但是我想在关闭那个保存文件的对话框后再做一些操作,但是window.open()这个函数还没执行完,就是还没有返回结果时,程序就去执行window.open()下面的语句了。(我也用过window.showModalDialog,这个函数在IE下不能执行action)。

解决方案 »

  1.   

    仅一个思路,你可自行扩展// a.html
    var o = window.open('b.html');
    var t = null;
    function getOpenPageValue(){
    var v = o.document.getElementById("b").value;
    if(v != "123"){
    t = setTimeout("getOpenPageValue()", 10);
    }else{
    clearTimeout(t);
    alert(v);
    }
    }
    getOpenPageValue();// b.html
    <input type="hidden" id="b">
    <script>
    /*
    do something ...
    */
    document.getElementById("b").value = "abc";
    </script>
      

  2.   


    这样不行,比如说:
    var o = window.open('report.action');
    var t = null;
    getOpenPageValue();那个window.open()是生成报表的,需要一定时间,所以o为null,所以在getOpenPageValue()
    o一直为null,所以就一直执行setTimeout中的function。主要是判断window.open()什么时候结束,这个有什么相应事件没?
      

  3.   

    var o = window.open('report.action');
    setTimeout(function(){
        if(o){
           alert('页面加载成功')
        }
    },100)
    只能这样用setTimeout判断了
      

  4.   


    var o = window.open('report.action');
    这个只赋值一次,如果赋值的时候window.open()没有执行完成,o就为null,等到window.open()执行完成后o仍然为null,所以setTimeout这个也没法判断呀
      

  5.   


    你不是只执行一次这个window.open吗~·如果页面窗口打开了,那么o肯定不会是null。
      

  6.   


    var o = window.open('report.action');
    alert(o);
    如果open一个普通的页面,那么o不会是null。现在里面是一个action,需要大概10s的时间,这样给o赋值的时候,window.open()还没有完成,alert(o)弹出的是个[Object]。过10秒窗口打开了,但是o仍然没有值,因为这个时候没有给它赋值。
      

  7.   

    你可以讲某些代码防盗clearTimeout()附近,或者用setTimeout做一个slepp睡眠功能这都很好弄的
      

  8.   

    // a.html
    var o = window.open('b.html');
    var t = null;
    function getOpenPageValue(){
    if(o.document.getElementById("b") == null || !o.document.getElementById("b").value){
    t = setTimeout("getOpenPageValue()", 100);
    }else{
    clearTimeout(t);
    alert("Load allready.");
    alert('Contrinue go.');
    /*
    Contrinue exec codes ...
    */
    }
    }
    getOpenPageValue();// b.html
    <input type="text" id="b">
    <script>
    setTimeout("document.getElementById('b').value='abc';", 2000);
    </script>