我有一个申请html5模式=真,但在 IE 上我不需要回退到#/url。我需要的是保留 URL 并重新加载完整的页面。
如果我找不到任何方法,我将需要编辑 AngularJS 文件,而这正是我不想要的。
建议?
Thanks!
- 编辑 -
作为临时解决方案,我评论了 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,并且 Browser.url 会创建一个位置.href如果浏览器不支持历史API。
我想这就是你想要的。如果不是,也许解决方案涉及相同的事件$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 检查,请参阅这篇文章。 https://stackoverflow.com/questions/10964966/detect-ie-version-in-javascript
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)