【问题标题】:window.location.href hash navigation for jquery mobile not working with Internet Explorerjquery mobile 的 window.location.href 哈希导航无法与 Internet Explorer 一起使用
【发布时间】:2015-06-21 11:15:24
【问题描述】:

javascript:

function changeView(newViewDiv){
    window.location.href = "#"+newViewDiv;
}

在我的 javascript 代码的不同位置,我使用此函数浏览不同的 jquery 移动页面 例如:-

<div data-role="page" id="addpage">...</div>

要查看上面的页面,我在我的 js 代码中使用了 changeView('addpage')。 这适用于 chrome、safari、firefox 等,但不适用于 Internet Explorer。浏览器的 url 更改为 http://example.com/index.html#addpage 但页面未显示。有人有这个解决方案吗?

【问题讨论】:

  • 何时/如何调用该方法?什么版本的 IE?
  • 在 jQuery Mobile 中,您应该使用 pagecontainer 小部件更改方法导航页面:api.jquerymobile.com/pagecontainer/#method-change, $( ":mobile-pagecontainer" ).pagecontainer( "change", "#" + newViewDiv, { transition : "幻灯片" });

标签: javascript internet-explorer jquery-mobile hash


【解决方案1】:

你可以试试这个

window.location= "#"+newViewDiv;

document.location = "#"+newViewDiv;

还要确保您的 newViewDiv 参数的值正确

【讨论】:

  • 也尝试过,但没有运气。参数值都很好,与其他浏览器配合得很好。
【解决方案2】:

感谢ezanker 的评论问题解决了。 window.location.href hash navigation for jquery mobile not working with Internet Explorer

答案: 在 jQuery Mobile 中,您应该使用 pagecontainer 小部件更改方法导航页面:api.jquerymobile.com/pagecontainer/#method-change,

$( ":mobile-pagecontainer" ).pagecontainer( "change", "#" + newViewDiv, { transition: "slide" });

--伊扎克

【讨论】:

    【解决方案3】:

    是的,我在移动浏览器上使用了window.location= url;,它成功运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-10
      • 1970-01-01
      • 2012-11-30
      • 1970-01-01
      • 2013-06-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多