• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 493
  • Last Modified:

IFRAME and the parent page

I have this page that contains a flash object that shows a map for a country with its cities as links,clicking on a city link is supposed to load text specific to each city in an ifram, so the target of each link is the ifram with a querystring parameter of the city name, what I'm asking about is there a way for the parent page the one that includes the ifram & the flash to access the querystring parameter passed to the ifram, cos there is a link on the parent page called photogallery which when clicked is supposed to load the photogallery of the city the user clicked on the map,so how can I know which city is clicked except from the parameter sent to the ifram.

Hope my problem is clear,thanks.
0
JessyEzzy
Asked:
JessyEzzy
  • 3
  • 2
1 Solution
 
ThaSmartUnoCommented:
in your iframe page you could add
<script type="text/javascript">
opener.setCity(location.search.substr(1));
</script>

and in your main page (with the iframe and flash)
have
<script type="text/javascript">
 var tcity='';
 function setCity(city){ tcity=city };

 function showImage(){
  window.location.href="/myimages/photogallery.asp?"+city;
 }
</script>

and your link to load photogallery
<a href="#" onclick="showImage(); return false;">Photogallery</a>
0
 
JessyEzzyAuthor Commented:
Where am I'm supposed to add the code in the ifram, and what does substr(1) refers to why 1 and not 0?

Thanks.
0
 
ThaSmartUnoCommented:
substr(1) because location.search = "?" & querystring
so substr(1) gives you querystring

so im assuming your iframe gets a url like openpage.asp?somecity ... or
openpage.asp?city=somecity

and anywhere (easiest would just be at the top)
0
 
JessyEzzyAuthor Commented:
Thanks it's done, but I used window.parent.setCity instead of opener cos it gave me an error.
0
 
ThaSmartUnoCommented:
ok well glad that worked =)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now