我得到一个在 iframe 中显示外部内容的页面。内容显示正常,但是当加载 iframe 的内容时,当前页面的另一个副本被添加到浏览器历史记录中。这会导致浏览器后退按钮功能出现问题。
我根据所选语言获取内容的路径,然后从资源 token 获取路径。
内嵌框架
<iframe ng-if="path" style="height: 90%; background-color: transparent" allowtransparency="true" class="w-full" ng-src="{{path}}" name="storyFrame" frameborder="0"></iframe>
路径加载
$http.get(LRM.getUrl('scormToken', scope.selectedLang.scorm_package.resource_token))
.success(function (response) {
scope.path = response;
}).error(function (response) {
toaster.pop('error', '', 'Could not fetch scorm package');
});
问题是,如何在不添加到浏览器历史记录的情况下加载 iframe 内容?
最佳答案
尝试使用
scope.path = $sce.trustAsResourceUrl(response)
并在 Controller 中包含 $sce。 我不确定这一点,但我知道 angular 有时会出现 ng-src 和 iframe 的问题
编辑:
我现在发现我的 iFrame 和你的一样,我添加了新变量,我们称之为 showIframe,在我更改 src 之前我将它设置为 false,在我更改 src 之后将它设置为 true(超时没有毫秒数- 自动),所以我的框架被删除并添加到 DOM 并且历史没有改变。
关于javascript - iframe 和 angularjs 的浏览器历史记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33075981/