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

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!
0
electricd7
Asked:
electricd7
  • 4
  • 3
1 Solution
 
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
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
Michel PlungjanIT 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
 
Vee_ModCommented:
Force accepted.
Vee_Mod
Community Support Moderator
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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