Amr Elgarhy
Amr Elgarhy

Reputation: 68902

how to access iframe parent elements?

What i am doing is a new image uploader, i want to put the input file in the iframe and show the uploaded images in the parent page. So how can i access the parent elements from the inner iframe? or if some one have an example, that will be nice as well.

Upvotes: 0

Views: 1309

Answers (4)

cjk
cjk

Reputation: 46415

Frame object .parent will allow you to access the outer, or even document.top. If the two pages are not on the same domain your browser will likely block the script execution as an XSS attack.

Upvotes: 2

leppie
leppie

Reputation: 117220

I dont think you can, else I could just inject my IFRAME into your page, and go ape. From a security point of view.

Upvotes: 0

pestaa
pestaa

Reputation: 4749

You have limited options since iframes are not compatible browser-wide.

If you really stick to it, you can have it done only via server-side. JavaScript handles iframes incorrectly in many contexts, it is insecure, uncertain and doubtedly.

If you are open-minded enough, check out Ajax frameworks to change your uploading iframe into a smooth and effective uploader.

If you're interested in the latter, examples might be available on the air.

Upvotes: 0

Related Questions