954,598 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

url variables, iframes, and ???

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?

dlacloche
Newbie Poster
15 posts since Aug 2008
Reputation Points: 10
Solved Threads: 1
 

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.

efaith77
Light Poster
25 posts since Sep 2006
Reputation Points: 14
Solved Threads: 2
 

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>
<head>
bla bla
</head>
<body>bla bla
<iframe src="<?php echo $something; ?>" width='bigenough' height='tallenough' frameborder='0'>iframe</iframe>
</body></html>

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

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

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){[INDENT]window.location='target.asp?param='+target;[/INDENT]}


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="javascript:window.top.nav(1)">link1</a>
<a href="javascript:window.top.nav(2)">link2</a>
<a href="javascript:window.top.nav(3)">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.

DISCLAIMER:
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.

Cheers.

agrothe
Junior Poster
153 posts since Jun 2006
Reputation Points: 37
Solved Threads: 18
 

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

dlacloche
Newbie Poster
15 posts since Aug 2008
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You