This is boggling my mind right now.

Here's what a client wants:

On the index page, there is an iframe with links inside it. When you click on a link, it opens the page (not in the iframe, but in the top level) and sends a url string variable. This 2nd page (or details page) also contains an iframe that has dynamic content inside of it that needs to be displayed based on which link was clicked from the index page's iframe.

How do I get the variable from the url string to be available for use inside the iframe of the second page?

Recommended Answers

All 4 Replies

What you have there is a very unique problem. I can not think of a reason anyone would want to do that. You could probably acheive this effect with some Java script.

I can do it in php => implies there is a method in ASP
but why an iframe
an include menu is more compliant with more browser types that dont support iframes
any how

in the iframe menu

<a href='/index.php?something=value1' target='_top'>page1</a>
<a href='/index.php?something=value2' target='_top'>page2</a>
<a href='/index.php?something=value3' target='_top'>page3</a>
<a href='/index.php?something=value4' target='_top'>page4</a>
<a href='/index.php?something=value5' target='_top'>page5</a>
<a href='/index.php?something=value6' target='_top'>page6</a>

index.php page

<!doctype blah bla>
<html blah bla>
bla bla
<body>bla bla
<iframe src="<?php echo $something; ?>" width='bigenough' height='tallenough' frameborder='0'>iframe</iframe>

cant guarantee the syntax for ASP but there must be an analog

Ok, this isn't really hard. You just need javascript. Of course navigation with JavaScript is almost never a good idea, but here is how.

I'm assuming you have a page called index.asp. index.asp has an iframe called iframe_index.asp. We will link to a page called target.asp with an iframe called target_iframe.asp.

So first your javascript. In the head of your index.asp put:

function nav(target){

Ok, so this javascript function navigates to target.asp with a dynamic param querystring.

On our iframe_index.asp we have the following links:

<a href="">link1</a>
<a href="">link2</a>
<a href="">link3</a>

This code calls the nav function on our index.asp page and redirects us to target.asp

Target.asp uses the following iframe:

<iframe src="target_iframe.asp?param=<%=request.querystring("param")%>"></iframe>

Now, in your target_iframe.asp code, you can do another request.querystring("param") to get the value passed from the iframe_index.asp page and do whatever with it.

Your iframes must reside on the same domain and server in order for this to work, and you may have some cross-browser issues. I don't recommend using this, but this is how you can do it. You could use sessions and ajax and a few other methods as well.


Okay. Cool. Thanks for all the help. I'm going to read thru this thread a few times then give it a try!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.