function f1(){
   refresh();//刷新href.jsp頁面
   其他函數
}
function refresh(){
    window.frames['iframename'].location.href = '/../../href.jsp';
}
在調用f1()時總是先執行其他函數再回來執行refresh(),怎麼讓refresh()執行完再執行下面的語句javascript

解决方案 »

  1.   

    其他函数...function others(){
    其他函数;
    }写
    refresh();//刷新href.jsp頁面
    setTimeout(others,0);试试这个
      

  2.   

    在这个页面 /../../href.jsp 
    window.onload = function(){
        window.parent.回调方法();
    }主页面写个回调函数
    function 回调函数{
       //f1里面的 其他函數
    }
      

  3.   

      window.frames['iframename'].onload=function(){}
      

  4.   

    就是这样,我给整理一下function f1(){
       refresh();//刷新href.jsp頁面
       window.frames['iframename'].onload=function(){
          其他函數
       }
    }
    function refresh(){
        window.frames['iframename'].location.href = '/../../href.jsp';
    }
      

  5.   

    JS是顺序执行的啊。。<!doctype html>
    <html>
    <head>
    <script type="text/javascript">
    alert("a");
    </script>
    </head>
    <body onload="alert('c');">
    <script type="text/javascript">
    alert("b");
    </script>
    </body>
    </html>
      

  6.   

    JS是异步执行的吧,比如$.ajax{}想要同步就得加参数async:false,我现在想知道普通JS函数同步需要怎么处理?
      

  7.   

    setTimeout(others,1000),数值改大一点问题就解决了,谢谢
      

  8.   

    ajax可以发出请求异步回调
    但是JS代码是顺序解释的
    http://www.oncoding.cn/2009/javascript_execution_sequence/