3

我有一个html5Mode = true的应用程序,但在 IE 上我不需要回退到#/url。我需要的是保留 URL 并重新加载完整的页面。

如果我找不到任何方法,我将需要编辑 AngularJS 文件,这就是我不想要的。

建议?

谢谢!

- 编辑 -

作为临时解决方案,我在 AngularJS 文件中注释了一些代码。

/*if ($sniffer.history) {*/
    $location = new LocationUrl(
      convertToHtml5Url(initUrl, basePath, hashPrefix),
      pathPrefix, appBaseUrl);
  /*} else {
    $location = new LocationHashbangInHtml5Url(
      convertToHashbangUrl(initUrl, basePath, hashPrefix),
      hashPrefix, appBaseUrl, basePath.substr(pathPrefix.length + 1));
  }*/

现在它不会回退到 Hashtag url,如果浏览器不支持历史 API ,Browser.url 会创建一个location.href 。

4

1 回答 1

0

我认为这可以满足您的要求。如果不是,也许解决方案涉及相同的事件$locationChangeStart

  var gate = 1;
  $scope.$on("$locationChangeStart", function(event, nextLocation, currentLocation) {
    if ($('html').is('.ie6, .ie7, .ie8')) {
      if (gate === 0) { //prevent endless location change
        gate = 1;
        window.location.href = nextLocation; //reload the page
      }
      else {
        gate = 0;
      }
    }
  });

如果您不知道此 OldIE 检查,请参阅此帖子。

于 2013-11-27T03:14:54.927 回答