I am redirecting any page that is not in frame to index.html. The index is being changed to index.html?page.html
I want to use the additional part from address and set the SRC of the frame to this value.
I don't know how to include location.search.substring(1) correctly so it wouldn't cause errors.
Each site has code:
if (top.location == self.location)
{
top.location = 'index.html?' + location.href.replace(/^.*[\\\/]/, '');
}
The index page contains right after
<frameset rows="100px,100%" cols="*" border="0">
<frame src="logo.html" name="logo" scrolling="no">
<frameset rows="*" cols="200,100%" border="0">
<frame src="menu.html" name="menu" scrolling="no">
<script language="javascript">
if (location.search && location.search.length > 1 && location.search.charAt(0) == "?")
{
document.write('<frame src="' + location.search.substring(1) + '" name="page" scrolling="auto">');
}
else
{
document.write('<frame src="main_page.html" name="page" scrolling="auto">');
}
</script>
</frameset>
</frameset>
I got this idea from my previous question.
BTW. Should I even do this? Is there any better solution?
locationis an global object in each frame (window-object). It should be refered like:top.window.locationorwindow.location.locationitself does not represent the present URL of the page, that can be found from it's property namedhref, if not already redirected.hrefis also used to change the URL of the page.