Access Variable from iframe

G

Gernot Pfeifer

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.location.reload(true);
[...]

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
 
T

Tim Streater

"Gernot Pfeifer" <[email protected]> said:
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.location.reload(true);
[...]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top