471,338 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

Passing a value from the parent to the iframe

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
Jul 23 '05 #1
2 2614
Jim wrote:
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+"&Ran k="+var2;
And use asp or js to parse the query string.

Mick

thanks

-Jim

Jul 23 '05 #2
> 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
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Xerxes | last post: by
11 posts views Thread by HolaGoogle | last post: by
3 posts views Thread by hendedav | last post: by
3 posts views Thread by Kieran Benton | last post: by
2 posts views Thread by Yazeed_Roumer | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.