electricd7
asked on
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!
ASKER
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?)
var cat = parent.location.search; // grab ?catid=..... from the parent
if (cat.indexOf('categoryid')
(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?)
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
That also means that the frameset cannot come from harddisk or network drive while the iframe content comes from a web server
ASKER
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?
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
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
ASKER
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!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Force accepted.
Vee_Mod
Community Support Moderator
Vee_Mod
Community Support Moderator
<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)
}
</script>