I'm trying to disable my url from changing wit

2019-09-09 15:29发布

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条回答
男人必须洒脱
2楼-- · 2019-09-09 16:04

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>
查看更多
登录 后发表回答