window.location.href jquery 移动设备的哈希导航不支持 Internet Explorer
window.location.href hash navigation for jquery mobile not working with Internet Explorer
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但是页面不显示。有人对此有解决方案吗?
你可以试试这些
window.location= "#"+newViewDiv;
或
document.location = "#"+newViewDiv;
还要确保您的 newViewDiv
参数的值正确
感谢ezanker的评论问题解决了。
答案:
在 jQuery Mobile 中,您应该使用 pagecontainer 小部件更改方法导航页面:api.jquerymobile.com/pagecontainer/#method-change,
$( ":mobile-pagecontainer" ).pagecontainer( "change", "#" + newViewDiv, { transition: "slide" });
– ezanker
是的,我使用 window.location= url;
移动浏览器并且它的工作成功。
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但是页面不显示。有人对此有解决方案吗?
你可以试试这些
window.location= "#"+newViewDiv;
或
document.location = "#"+newViewDiv;
还要确保您的 newViewDiv
参数的值正确
感谢ezanker的评论问题解决了。
答案: 在 jQuery Mobile 中,您应该使用 pagecontainer 小部件更改方法导航页面:api.jquerymobile.com/pagecontainer/#method-change,
$( ":mobile-pagecontainer" ).pagecontainer( "change", "#" + newViewDiv, { transition: "slide" });
– ezanker
是的,我使用 window.location= url;
移动浏览器并且它的工作成功。