Passing a value from the parent to the iframe

J

Jim

I want to pass a value from the parent to the iframe when I click a
button, the parent will reload and the iframe should show the data I
need...

when the iframe loads I want it to run something in asp based on the
value I send it..how can I go about doing this?

thanks

-Jim
 
M

Mick White

Jim said:
I want to pass a value from the parent to the iframe when I click a
button, the parent will reload and the iframe should show the data I
need...

Strictly speaking, the page in which the iframe resides and the iframe
are siblings. When you reload the "parent", you start from scratch, any
value of variables you may have set after the original page load will
be lost.
when the iframe loads I want it to run something in asp based on the
value I send it..how can I go about doing this?

Instead of reloading you could attach a query string to the location:

location=(location.toString())+"?Name="+var1+"&Rank="+var2;
And use asp or js to parse the query string.

Mick
 
J

Java script Dude

I want to pass a value from the parent to the iframe when I click a
button, the parent will reload and the iframe should show the data I
need...


Be sure to use window.frames["frame name"] to access the iFrame. This
access property will give you the window object of the iFrame and
should work in all browsers. IE also exposes properties directly off
the iFrame element but I suggest avoiding them as they are mostly
unsupported by other browsers.

If your iFrame is named ifTest ( <iframe name='ifTest'... )the you can
get the window object of the iFrame by var w=window.frames["ifTest"].
Have your JS event set the window.location.href of the iFrame to the
URL you want including the proper query parameters in the get. Your
ASP page receiving the request would parse the query parameters from
the get and do whatever you wish.

Hope this helps,

JsD
 

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
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top