content of dynamically created iframe is empty

前端 未结 2 1096
轻奢々
轻奢々 2021-01-11 10:26

On my localhost, I am using the following JavaScript to create an iframe with src, and add it to the document:

$(\'#preview\').html         


        
2条回答
  •  北荒
    北荒 (楼主)
    2021-01-11 10:46

    If you'd checked your browser's error console, you'd have seen this message:

    Refused to display document because display forbidden by X-Frame-Options.

    So, this isn't an error on your part, but a deliberate action on the part of Google.

    The two options for the X-Frame-Options are:

    • deny - no rendering within a frame, and
    • sameorigin - no rendering if origin mismatch

    References:

    • X-Frame-Options response headers, at MDN.
    • X-Frame-Options at Wikipedia.
    • Overcoming "Display forbidden by X-Frame-Options" (here on Stack Overflow).

提交回复
热议问题