我正在尝试在不禁用jQuery Mobile的Ajax的情况下禁止更改我的URL [英] I'm trying to disable my url from changing without disabling ajax in jquery mobile
问题描述
当我在IE中(有时是chrome)浏览到项目中的其他页面时,新URL将添加到旧页面中.
When I navigate to a different page in my project in IE (and sometimes chrome) the new URL is added to the old one.
例如,如果这是我的原始URL:localhost:49866/Home/Index
For example, if this is my original URL: localhost:49866/Home/Index
然后我导航到另一个页面,将URL像这样添加到旧页面中:
and I was to navigate to a different page, that URL is added to the old one like this:
localhost:49866/Home/Index#/Newpage
localhost:49866/Home/Index#/Newpage
我发现这是一个ajax的东西,可以更轻松地检索旧页面.但是,有没有一种方法可以在不禁用我的Ajax的情况下解决此问题?
I've found that this is an ajax thing which makes it easier to retrieve old pages. However, is there a way to fix this without disabling my ajax?
我发现的唯一解决方案是使用此脚本完全禁用我的ajax:
The only solution I've found is to disable my ajax completely using this script:
$(document).ready(function () {
if ($.browser.msie || $.browser.webkit) {
$("a").attr("data-ajax", "false");
$("a").attr("rel", "external");
var a = $("form");
if (a != null) {
$("form").first().attr("data-ajax", "false");
$("form").first().attr("rel", "external");
}
}
});
推荐答案
您可以在每个jquery-mobile页面上设置所需的任何url.像这样在您的data-role ="page" div上使用data-url属性:
You can set any url you want on each of your jquery-mobile pages. Use the data-url attribute on your data-role="page" div like this:
<div id='myJQMPage' data-role="page" data-url="/the/url/i/want")>
</div>
这篇关于我正在尝试在不禁用jQuery Mobile的Ajax的情况下禁止更改我的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!