Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking to see if a Parent exists 1

Status
Not open for further replies.

pUsHter

Programmer
Joined
Apr 14, 2003
Messages
3
Location
US
Hello, I was wondering if anybody knew of the way to recognise if there is a parent to a page loaded.

I have an index.php which loads two iframes, and it works perfectly, though there is one problem. If someone accesses one of the pages embedded in it directly, the index.php won't be loaded around it.

So basically, index.php calls navigator.php and content.php as its child iframes. If content.php was loaded by itself, is there a code that I can use to recognise that? I tried this for days off end a long time ago and never was successful.

Now I did look into solving this via the PHP end, however if you happen to know PHP, I discovered that $HTTP_REFERRER is not very reliable. =/

Hmm, not anything extremely important to have, but it would be nice, and I've got so many other things to do at the moment, so if someone happened to know this offhand that would be greatly appreciated.. Thank you!!!
 
I'm using this script (put this in the <head> 'content.php'):

<SCRIPT LANGUAGE=&quot;JavaScript&quot; TYPE=&quot;text/javascript&quot;>
<!--
var go_to = location.href.substring(location.href.lastIndexOf(&quot;/&quot;)+1);

if ((top != self.parent) || (top == self))
{
top.location.replace('../index.php?path/to/directory/' + go_to);
}
// -->
</SCRIPT>

and this in the 'index.php':

<SCRIPT LANGUAGE=&quot;JavaScript&quot; TYPE=&quot;text/javascript&quot;>
<!--
var query = (location.href.indexOf(&quot;?&quot;)+1);
var page = 'default.php'

if (query)
{
page = location.href.substring(query);
}


document.write('<frameset cols=&quot;200,*&quot; frameborder=&quot;NO&quot; border=0 framespacing=0>');
document.write('<frame src=&quot;navigator.php&quot; name=&quot;leftFrame&quot; scrolling=&quot;NO&quot; noresize>');
document.write('<frame name=&quot;mainFrame&quot; src=' + page + ' scrolling=&quot;auto&quot; NORESIZE>');
document.write('</frameset>');

</SCRIPT>


Don't eat yellow snow!
 
where 'top.location.replace' is the path to index.php (in my case one directory up) and after that the path to the file (compared to index.php) where you're putting this script into...

Quasibobo

Don't eat yellow snow!
 
Woohoo! It works! Used a different method in the index.php section, but the content.php part worked perfectly! Thanks a lot! :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top