Need to redirect content in IFRAME based on querystring of parent frame. ASP / JAVASCRIPT

I have a page on a corporate webserver which I have opened an IFRAME in.  The main page is called: Category.asp.  The IFRAME points to "gallery.asp".  What I would like is to be able to do is link to Category.asp?catid=4 and then somehow within gallery.asp pull the catid from the main frame's querstring and redirect the IFRAME to gallery.asp?catid=4.  I am just not sure how to access the parent frames querystring in order to do this.  I will accept code in ASP or JavaScript but would prefer ASP.  Thanks in advance!
electricd7Asked:
Who is Participating?
 
Michel PlungjanConnect With a Mentor IT ExpertCommented:
Sorry, must have missed this...

If you still need the solution it is either

<script>
document.write('<iframe src="page.ext'+location.search+'"></iframe>')
</script>

or

<iframe name="if1" src="about:blank" onLoad="window.if1.location='page.ext'+location.search"></iframe>
0
 
Michel PlungjanIT ExpertCommented:
<html>
<head>
<script>
function loadIt() {
  if (parent.frames.length==0) return; // we are not in frames
  var cat = parent.location.search; // grab ?catid=..... from the parent
  if (cat.indexOf('catid')!=-1) location.replace('gallery.asp'+cat); // replace using ?catid=...
}
</script>
 
0
 
electricd7Author Commented:
Ok, I added that code to the HEAD in my gallery.asp page and then put an OnLoad function calling it in the <BODY> tag for gallery.asp.  I now get an "Permission Denied" javascript error on line 7 which in this case is:

var cat = parent.location.search; // grab ?catid=..... from the parent
if (cat.indexOf('categoryid')!=-1) location.replace('gallery.asp'+cat); // replace using ?catid=...

(Not sure which is really line 7, because it looks like the top line is blank, so I am not sure if it is counting it?)
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
Michel PlungjanIT ExpertCommented:
All pages have to come from the same server!

That also means that the frameset cannot come from harddisk or network drive while the iframe content comes from a web server
0
 
electricd7Author Commented:
Yea that is not the case here.  The IFRAME page is on a different server than the Parent frame.  There is no way to get the querystring of the PARENT from inside the IFRAME somehow?
0
 
Michel PlungjanIT ExpertCommented:
Not from a "normal" web page
If you save your parent page with extension .HTA and add
application="yes"
to the iframe tag, then you can open the hta from harddisk or save and load it from a web server.
Otherwise no
0
 
electricd7Author Commented:
Ok what about this:  On the same server where the IFRAME is called, how can I get the categoryid from the main page's querystring and add it to the <IFRAME> SRC line?  Is that possible?  It would have to be a client side code, as I can't execute server side scripts on the parent frame server.  Thanks!
0
 
Vee_ModCommented:
Force accepted.
Vee_Mod
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.