Is there a way to prevent an iframe from redirecting parent window, but in such a way that “top level” redirects still work inside the iframe itself?

后端 未结 2 1370
情歌与酒
情歌与酒 2021-02-12 15:41

So I\'ve read about the HTML5 sandbox property and I understand that if I want to prevent an iframe redirect its parent window I can use the sandbox property leavin

2条回答
  •  温柔的废话
    2021-02-12 15:52

    With HTML5 the iframe sandbox attribute was added.

    At the time of writing this works on Chrome, Safari, Firefox and recent versions of IE and Opera but does pretty much what you want:

    Allows the iframe content to be treated as being from the same origin as the containing document

    
    

    Browser Compatibility enter image description here


    Some Useful links

    • w3schools for sandbox
    • developer.mozilla.org iframe
    • -

提交回复
热议问题