Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i access Iframe #document with javascript

I have this frame i cannot access,from initial inspection of the frame i noticed the frame contained a #document then i wrote a code to access the frame.

$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;        

The last line returns restricted,and
iframe.contentDocumentreturns null. Then i tried to access the frame document which is a #document withiframe.children[0]it returned undefined,then i left the array open but nothing happened.All codes i run on the frame returns undefined how do i access this frame #document?yoyoyo.

like image 596
Tobisky Avatar asked Sep 02 '26 08:09

Tobisky


1 Answers

iframe.contentWindow.document but only if the origin is the same, because of Same-origin policy.

like image 68
Emeeus Avatar answered Sep 05 '26 01:09

Emeeus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!