0

我在 Android 移动设备上看到一个与 History API 相关的奇怪问题。我运行一些代码来更新页面 url history.pushState,然后检查window.location.href. 我希望 的值href等于我刚刚推送的值,但它仍然具有以前的值。当我检查浏览器 url 栏时,位置已正确更新。此代码重现了该问题:

function go(){
    console.log(window.location.href); // this shows url of '.../page1.html'
    window.history.pushState({}, '', './page2.html');
    console.log(window.location.href); // this still shows url of '.../page1.html'
    // browser address bar shows url of '.../page2.html'
}

我在默认的 Android 2.3.4 浏览器上看到了这个问题,当我在桌面浏览器中运行相同的代码时,它的行为与我预期的一样(即window.location.href具有我推送的值) - 任何人都可以确认这是一个浏览器错误,而不是预期的行为?

4

1 回答 1

1

请参阅 android 错误报告 http://code.google.com/p/android/issues/detail?id=17471

于 2012-09-03T11:51:50.303 回答