markie
markie

Reputation:

How to access main window element from iframe

I hope someone can help with this issue. I have a popup iframe using lytebox. I would like it that when I click a link in my iframe with the class mylink that it executes the AJAX call and update a div in my main window with the id="mydiv". I know how to do the onclick events and the ajax call but I do not know how to access the mydiv from the main window and update it with the content. Any help on this would be greatly appreciated. Thanks.

Upvotes: 0

Views: 768

Answers (1)

Paolo Bergantino
Paolo Bergantino

Reputation: 488744

You can simply use window.parent.document to access the parent document from the iframe.

jQuery allows you to specify a context for searches, so you could then do:

$(myselector, window.parent.document);

Upvotes: 1

Related Questions