By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,442 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,442 IT Pros & Developers. It's quick & easy.

how Iframe access varible from other frame?

P: 123

I have a page, it include a iframe inside, but how to make the iframe can access
the variable from it outer frame?

outframe id= have a variable ...var intnumber,
iframe id=framein.

Expand|Select|Wrap|Line Numbers
  1. if (top.document.frameout.intnumber=="1")
  2. {
  3. }
  4. else
  5. {
  6. }
I use something like above, it not work..please help...
I have tried parent.document.frameout.intnumber as well...
Nov 13 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 101
Javascript global variables are properties of window object, so accessing global variable of parent's frame would look like:

if (parent.intnumber == 10) { ....

It's better to address frames relatively, because you can not know if you will not put the whole conent into one more iframe in the future (so top will address different frame).

so to access parent frame use "parent",
to access child frames use: "frames["name_of_child_frame"]"

EDIT: and dont forget you can access differen frame's content only if they are from the same domain.
Nov 13 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.