[英]Get all element from within an iFrame
How to get all element within an iFrame? 如何获取iFrame中的所有元素? I am using some javascript code here but I don't know what I do next and how to get all element inside in iframe:
我在这里使用一些javascript代码,但我不知道接下来要做什么以及如何将所有元素放入iframe中:
<iframe id="uploads" src="https://jsfiddle.net/mekwall/up4nu/"></iframe>
var iframe = document.getElementById('uploads');
var innerDoc = iframe.contentDocument;
I'm using contentDocument
it's gives only <html><body></body></html>
我正在使用
contentDocument
它仅提供<html><body></body></html>
Hello this is your code executed in jsfiddle. 您好,这是您在jsfiddle中执行的代码。 Its showing error in console.
它在控制台中显示错误。
see screenshot: http://prntscr.com/c54jts 看到截图: http : //prntscr.com/c54jts
The reason for that error is mentioned here: 该错误的原因在这里提到:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Property_access_denied https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Property_access_denied
For more details: https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy 有关更多详细信息: https : //developer.mozilla.org/zh-CN/docs/Web/Security/Same-origin_policy
Summery: You can't access the content of iframe if its from different domain. Summery:如果iframe的内容来自其他域,则无法访问它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.