I’m trying to copy information from an iframe to my document, I wrote this
<iframe class="Number" frameborder="0" allowtransparency="true">
<html>
<body id="wow">002-7375347
</body>
</html>
</iframe>
html = $("iframe").find("body").html();
document.write(html);
and it doesn’t work can somebody help me?
Thank you.
You can only do this if the iframe and the document running your javascript have the same
origin(same domain, port, protocol, a few other things). This is a security feature called the same origin policy implemented by all major browsers. You cannot really get around it.The rationale for this feature is to prevent the following (greatly simplified) scenario.
iframeand points it to your Amazon home page.The policy as implemented is broadly summed up as
So your code can
iframebut not be able to examine its contentsExploiting the fact that this is somewhat different to program correctly is a large part of what web hackers do.