2016-04-27 141 views
0

作为我的应用程序的一部分,我需要显示一个iframe作为一个页面。我需要在页面上提供后退和前进按钮,以便iframe可以在其历史记录中后退/前进。Phonegap Ionic - Iframe history.back();不工作

当我尝试:

$scope.backiframe = function() { 

    var iframe = document.getElementById('iframe'); 
    iframe.contentWindow.history.go(-1); 
} 

与我的按钮和iframe: <a class="button button-positive" ng-click="backiframe()">back</a> <iframe id="iframe" ng-src="{{trustSrc(url)}}" scrolling="yes"></iframe>

我得到以下错误: Error: Permission denied to access property "history" [email protected]://localhost:8100/js/controllers.js:1217:16 anonymous/[email protected]://localhost:8100/lib/ionic/js/ionic.bundle...

没有人知道如何让IFRAME前进/后退到在手机离子混合应用程序中工作?

+0

是iframe中引用外部URL? – Shakespeare

+0

是的iframe正在链接和外部URL – AN11

+0

可能重复[错误:无法访问属性href](http://stackoverflow.com/questions/15703503/error-cant-access-property-href) – Shakespeare

回答