问题
When I navigate to a different page in my project in IE (and sometimes chrome) the new URL is added to the old one.
For example, if this is my original URL: localhost:49866/Home/Index
and I was to navigate to a different page, that URL is added to the old one like this:
localhost:49866/Home/Index#/Newpage
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?
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");
}
}
});
回答1:
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>
来源:https://stackoverflow.com/questions/18018967/im-trying-to-disable-my-url-from-changing-without-disabling-ajax-in-jquery-mobi