Javascript 使用windows.location=";一些url“;更改,但元素(对象)来自旧url

Javascript 使用windows.location=";一些url“;更改,但元素(对象)来自旧url,javascript,jquery,html,ios,cordova,Javascript,Jquery,Html,Ios,Cordova,要重定向到iOS上PhoneGap上的URL,我在javascript中使用了以下代码 function pedirTaxi(){ var direccion = $('#txtDireccion').val(); alert(direccion); window.location.href = "loading.html"; cambiarBar(); ... } function cambiarBar(){ var ajaxs = 100;

要重定向到iOS上PhoneGap上的URL,我在javascript中使用了以下代码

function pedirTaxi(){
    var direccion =  $('#txtDireccion').val();
    alert(direccion);
    window.location.href = "loading.html";
    cambiarBar();
    ...
}

function cambiarBar(){
    var ajaxs = 100;
    alert($(this).attr("href"));
    ...
}
它仍然显示旧的url,即index.html。有人能告诉我我做错了什么吗?我已经尝试了一切,使用jquery(仍然是javascript)和window.location.replace或.assign,我真的被卡住了

调用函数pedirTaxi()的html位于index.html中,如下所示:

     <button class="btn btn-primary" onclick="pedirTaxi()">
            pedir taxi
    </button>

佩迪尔出租车

提前感谢

我认为您应该使用window.open而不是window.location.href,这只是一个属性


如果您想查看应用程序中发生的情况,可以使用chrome和disable-web-security选项以及调试模式(cmd+alt+j)打开它。

还有更多信息吗?你能在你的开发者工具中报告一些东西吗,例如loading.html会因为找不到而被重定向,等等。?更多信息将有助于我们理解,因为我在XCode上使用phonegap,无论是调试还是控制台,我都没有太多信息。但是loading.html确实加载了,它被找到了,但是元素没有改变,它保留index.html元素。我编辑了这个问题,我知道这是很少的信息。