Reputation: 20922
I have a website that runs out of an iframe.
To logout I run the following JavaScript with a URL and this works fine.
window.parent.location.href
I catch I have is sometimes if I don't exit the site correctly and then reconnect I endup with 2 iframes (potentially more).
Is there a way to make the following JavaScript find the outer most (the true parent) of all potential iframes?
window.parent.location.href
I want to make sure no matter how many iframes are present the redirection will still occur.
any advice would be great... thx
Upvotes: 1
Views: 128
Reputation: 19237
topParent = window;
while (topParent.parent) {
topParent = topParent.parent;
}
// do whatever you want on topParent
Upvotes: 0