3

I've got this message when try to put the url in iframe:

Refused to display '' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'".

I have angular app that create iframe component with onerror binding as suggested in this answer Angular way to set onerror on iframe, my angular 1.5 component iframe look like this:\

// iframe.controller.js
export default class iframeController {
    static $inject = ['$scope', '$element'];

    constructor($scope, $element) {
        // this display the iframe even that component have no template
        console.log($element.clone().wrap('<div/>').parent().html());
        $element.on('error', () => {
            console.log('error');
            var call = () => {
                this.onerror();
            }
            if (!$scope.$$phase) {
                $scope.$apply(call);
            } else {
                call();
            }
        });
    }
}

// iframe.component.js
import controller from './iframe.controller';

export default {
    bindings: {
        onerror: '&'
    },
    controller,
    controllerAs: 'vm'
};

I've got error in console but the function is not executed. How to solve this, is there a way to get the error if iframe is refusing to display the page?

Community
  • 1
  • 1
jcubic
  • 61,973
  • 54
  • 229
  • 402

0 Answers0