3

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.

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

13 Comments

How do i set the origin if the origin is not the same?
Unfortunately or fortunately we can't set the origin. If you need to access to document of other origin, there are two ways, perform an ajax GET/POST request only if server have Access-Control-Allow-Origin: yourDomine ( or *) developer.mozilla.org/es/docs/Web/HTTP/Headers/… OR perform a GET/POST from server side
i know how to configure an XHR but i don't know how to access the Access-Control-Allow-Origin header...
it's a server side header, if you don't control the server or this header is not present, the only way is perform a GET/POST from server side, not a browser. If you control the server it depends of the server code, but it's really easy.
Example in php: header('Access-Control-Allow-Origin: *');
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.