Reputation: 5689
I have a web page which contains a JavaScript variable called "myVariable".
Within this web page is an iframe which points to a second web page.
Both pages are within the same domain.
The page within the iframe needs to access "myVariable" which is defined in the parent web page.
I have successfully accessed this variable with Firefox using the following code:
document.defaultView.parent.myVariable
However, this does not work in Internet Explorer.....
How do I do this in Internet Explorer?
Upvotes: 4
Views: 8319
Reputation: 11412
Firefox 26.0, Internet Explorer 11, Chrome 32.0:
window.top.myVariable
window.top.document.myVariable did NOT work.
Upvotes: 1
Reputation: 262842
If both pages are from the same domain (like you say), window.top or window.parent should work to get to the parent frame.
window.top.document.myVariable
Upvotes: 5