Access Variable from iframe

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gernot Pfeifer

    #1

    Access Variable from iframe

    Hello together,

    I have the the following problem (since hours of Google-Search)...

    I have an HTML-Page (I will call it "Mainpage")
    On this Mainpage, I have an iFrame. I would now the iFrame to access
    Variables on my Mainpage.

    I tried the following:

    On the Mainpage
    [...]
    testvar="Hello World";
    iframename.loca tion.reload(tru e);
    [...]

    on the iFrame-Page
    [...]
    alert (parent.testvar );
    alert (testvar);
    alert (top.testvar);
    [...]

    Each time I got the window "undefined" .

    Thank you very much for you help und Greetings from Germany.

    Gernot


  • Tim Streater

    #2
    Re: Access Variable from iframe

    In article <fpet25$92o$1@a ioe.org>, "Gernot Pfeifer" <gernotpf@gmx.d e>
    wrote:
    Hello together,
    >
    I have the the following problem (since hours of Google-Search)...
    >
    I have an HTML-Page (I will call it "Mainpage")
    On this Mainpage, I have an iFrame. I would now the iFrame to access
    Variables on my Mainpage.
    >
    I tried the following:
    >
    On the Mainpage
    [...]
    testvar="Hello World";
    I think this may need to be:

    var testvar="Hello World";

    but I can't remember why. Certainly I do what you are attempting with no
    problems, but my declarations are as above.
    iframename.loca tion.reload(tru e);
    [...]
    >
    on the iFrame-Page
    [...]
    alert (parent.testvar );
    alert (testvar);
    alert (top.testvar);
    [...]
    >
    Each time I got the window "undefined" .
    >
    Thank you very much for you help und Greetings from Germany.
    >
    Gernot

    Comment

    Working...