Friday, April 15, 2022

[FIXED] How do you access the top level of the DOM from jQuery?

Issue

Trying to figure this out... I'm trying to accessthe top level of the dom from inside an iframe. How possible is this?


Solution

From inside of a frame you can always get to the top level using window.top. You can check to see if you are in a frame using:

var iAmInAFrame = (window.top == window.self);

You should be able to use window.top.document.whatever (e.g. body, getElementById(), etc.) to manipulate the top level document provided that you share a domain.



Answered By - Prestaul
Answer Checked By - Clifford M. (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.