javascript - How to circumvent same origin policy error to reference elements loaded in an iframe? -
there iframe following structure loaded via external site external.com
, being hosted @ domain example.com
:
<body> <!-- body of html i'm trying make reference --> <iframe> #document <html> <body> <script type="text/html" id="icon-close"><div class="icon icon-close"> <div class="icon icon close"</div> </script> </body> </html> </iframe> </body>
i'm trying select icon-close
element in case.
i can select iframe using $("iframe")
when try access contents in inspector code select elements using $("iframe").contents()
receive following:
domexception: failed read 'contentdocument' property 'htmliframeelement': blocked frame origin "https://external.com" accessing cross-origin frame.
i've tried setting domain.document = 'example.com'
before reference:
domexception: failed set 'domain' property on 'document': 'example.com' not suffix of 'external.com'.
i've tried setting external.com
:
domexception: failed read 'contentdocument' property 'htmliframeelement': blocked frame origin "http://example.com" accessing cross-origin frame.
i've seen related posts here , here don't understand how resolve this.
how can circumvent same origin policy access elements in iframe?
Comments
Post a Comment