how Iframe access varible from other frame?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • perhapscwk
    New Member
    • Sep 2007
    • 123

    how Iframe access varible from other frame?

    Hi,

    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= frameout....it have a variable ...var intnumber,
    iframe id=framein.


    Code:
    if (top.document.frameout.intnumber=="1")
    {
    }
    else
    {
    }
    I use something like above, it not work..please help...
    I have tried parent.document .frameout.intnu mber as well...
  • Dasty
    Recognized Expert New Member
    • Nov 2007
    • 101

    #2
    Javascript global variables are properties of window object, so accessing global variable of parent's frame would look like:

    if (parent.intnumb er == 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.

    Comment

    Working...