Reputation:
I have two iframes and each iframe show two different html pages. Both html pages refer to a common javascript file which contains a global variable. If I set the value of that global variable in one frame during html page load. Will the value be accessible using the same global variable to another iframe html page? why or why not?
Upvotes: 6
Views: 3155
Reputation:
Actually I'm noticing it doesn't seem to maintain scope and maybe someone can shed light on this.
Example 1: You have a HTML page with some Flash Content that has some functions to get the SWF Object and fire a command. When this page is loaded into a IFRAME the 'getSWFObj' is "not a function".
Example 2: I load a HTML Page that has a series of object based JavaScript files. I create a instance called "player" and it creates some sub objects like "navigation". When I call "player.navigation" I get a error saying it doesn't exist when loaded into a IFRAME.
Upvotes: 0
Reputation: 144172
No. The top level of JavaScript's scope space is the page level. However, you can access another page's scope by using window.parent
Upvotes: 11