Safari 连续执行两次window.location=url的问题
function(url1,url2){
 window.location=url1;
 window.location=url2;
}在Safari 里面第一条语句不会执行(或许不能这么说,反正是第一条想要的效果没有出现)修改成这样就OK,
function(url1,url2){
 window.location=url1;
 alert("OK");
 window.location=url2;
}试着另外加一个函数通过settimeout来执行window.location=url2;也是一样的问题,各位有什么好的办法吗?

解决方案 »

  1.   

    不可能,这种做法就是错误的,你对http的理解不够
      

  2.   

    可不可以讲的浅显点呢,我在IE和FF上面都是可以正常用的。其实这个就是通过mailto发mail,然后把这个动作记录到数据库。
      

  3.   

    在A页面上 执行 了 window.location=url1;现在到了B页面,B页面解析完毕之后,执行  window.location=url2;只能一次一个跳转
      

  4.   

    代码在下面,大家看看吧,url对应的动作只是 insert 一笔记录到数据库,然后回到当前页面.请注意:在IE和FF上面都是可以正常用的./*Send mail with mailto*/
    function sendEmailWithMailTo(toemailstr,ccemailstr,bccemailstr) {
    var mailstr = "mailto:";
    toemailstr  = encodeURIComponent(toemailstr);
    ccemailstr  = encodeURIComponent(ccemailstr);
    bccemailstr = encodeURIComponent(bccemailstr);
    mailstr = mailstr + toemailstr;
    if(ccemailstr !=""){
    mailstr = mailstr + "?cc=" + ccemailstr;
    if (bccemailstr != "") 
    mailstr = mailstr + "&bcc=" + bccemailstr;
    }
    else{
    if (bccemailstr != "")
    mailstr = mailstr + "?bcc=" + bccemailstr;
    }
    window.location = mailstr;
    }
    function sendDirectMail(jsonObj,url){
     sendEmailWithMailTo(jsonObj.simpleStr,"","");
     window.location=url;
    }
      

  5.   

    我也遇到同样的问题,加上一个alert(‘123’);
    就可以,这是为什么?
      

  6.   


    这个问题困扰我很久了,一个简单的系统,不能用Ajax,还要所有浏览器兼容,如果容许我们用Ajax的话,这个问题就不是问题了.
      

  7.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head><body>
    </body>
    </html>
    <script type="text/javascript">
    test1();
    function test1(){ 
    window.location="http://www.google.cn"; 
    alert("123");
    window.location="http://www.baidu.cn";
    }
     
    function test2(){
    gotoURL("http://www.google.cn");
    alert("123");
    gotoURL("http://www.baidu.cn");
    }function gotoURL(strURL){
    setTimeout(function(){
    window.location = strURL;
    },10);
    }</script>
    实测,页面遵循标准的话,不止是safari,所有浏览器都会这么做。
    因为你引用的是同一个window对象,即使页面跳转,内存中加载到window上的操作依然会继续执行。
    你用上面代码试试,设置浏览器的选项为链接在新窗口中打开你就会发现问题。
    你可以考虑用switch语句选择你所需的条件。
    或者你直接用window.open新开一个窗口避免在原窗口操作。