Log in

View Full Version : [Request] If not in frameset, go to a URL?



Moglizorz
01-07-2008, 06:38 PM
I am making a site, but I have no domain name at current. So I am using "www.co.nr" which hides your site in a frameset.

I wish to make it on my homepage, index.php, if it is not in the Frameset, it wall automatically redirect to the Framesetted page.

Example:
www.RandomURL.co.nr is frameset to "www.mysite.com/index.php".
I wish to make it when you go to "www.mysite.com/index.php" it will automatically go to www.RandomURL.co.nr with the frameset. I hope you understand what I mean :P

boogyman
01-07-2008, 07:03 PM
so basically you want to check what the URL Address of the page is, and if it is not the framed page you want to redirect to the framed page?

what language? Javascript / PHP / ASP ??? A server side program would be best because anyone can disable javascript on the client side and thus the redirect will not happen, but with php / asp or some other type of server side programming language the processing takes place before the page is sent back to the browser.

since you are using framed pages, I am going to assume you do not have access to a server-side language so the script below would need to be included on every page that you wish to check.



<script type="text/javascript">
if(top.location.href != "http://www.RandomURL.co.nr")
{
top.location = "http://www.RandomURL.co.nr";
}
</script>

Moglizorz
01-07-2008, 07:18 PM
Thanks :)

It's a php page btw, so anything would have worked :o

boogyman
01-07-2008, 07:27 PM
why are you using framesets if you have access to php?

I would suggest that you include the basic pages like (header, footer, navbar) and just do your processing on the "content" portion?


but as for your question since you have access to php.... I would use this instead



<?php

if( $_SERVER['HTTP_HOST'] != "http://www.RandomURL.co.nr" )
{
header("Location: http://www.RandomURL.co.nr");
}


rest of page
?>

Moglizorz
01-07-2008, 07:40 PM
Tried an include, it glitches up. Not sure why, but if I use an include, it completely ignores the include.

Twey
01-07-2008, 08:29 PM
Don't do this, it's an accessibility nightmare. Let your users break out of your frameset if they want to.

Moglizorz
01-08-2008, 04:17 PM
This is only until my host, my friend, gets his host to sort of php includes. Once he does that I'm fine, and I'll sort it.