我有这个框架我无法访问,从最初检查框架我注意到框架包含一个#document 然后我写了一个代码来访问框架。
$body = document.body;
$body.children[3];
$yo = $body.children[3];
$yo.children[0];
$next = $yo.children[0];
$next.children[3];
$plus = $next.children[3];
$plus.children[0];
$star = $plus.children[0];
$star.children[0];
$staragain = $star.children[0];
$staragain.children[1];
$nextstar = $staragain.children[1];
$nextstar.children[1];
$afternext = $nextstar.children[1];
$afternext.contentWindow;
最后一行返回restricted,and
iframe.contentDocument
返回 null
。
然后我尝试访问框架文档,它是一个带有iframe.children[0]
的#document,它返回undefined
,然后我让数组保持打开状态,但没有任何反应。所有代码我在框架上运行返回未定义如何访问此框架#document? yoyoyo .
最佳答案
iframe.contentWindow.document
但前提是来源相同,因为 Same-origin policy .
关于javascript - 我如何使用 javascript 访问 Iframe #document,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51004952/