Jump to content

Issue with html tabs and google searches


Lorne

Recommended Posts

I have a web site that uses tabs to load web pages into the contents area of the screen with a vertical menu on the left and a header across the top.  It works fine if users load the index page but google shows links to pages that should only show in the content pane so if users click these links they load without the tab menu or header.  How can I detect if one of these pages has been loaded directly and redirect it to the index file ?

If you want to see the problem https://www.cantab.net/users/bridge.analyser/Bridge/index.html loads the page correctly but https://www.cantab.net/users/bridge.analyser/Bridge/home.htm is what the user gets clicking a google result that is not the index file, so I want to redirect the second link to the index page but only if the user did not load the index page first.  I know how to do the redirect but I can't work out how to detect how the user got to the page so it only redirects when it needs to.

Link to comment
Share on other sites

Sorry I do not understand what you are saying.  It is a tab menu so clicking a tab loads the relevant html page into the tabcontents area of the page. I can't redirect the home page to the index page without a conditional statement because the index page loads the home page when the user click 'home' in the menu and it will keep reloading if there is no conditional statement to only go to the index page when the home page (or any other page that can be loaded via the menu) is loaded directly and not within the overall framework of the index file.

Link to comment
Share on other sites

I found a solution that works - I put this script in the <head> of each html page that has to be loaded in the tabcontent area of the page:

<script type="text/javascript">
  if (window.parent.document.title != 'Bridge Analyser') {
    location.replace('index.html');
  }
</script>

window.parent.document.title returns the title of the index page if the tabcontent was loaded by the index page but returns a different value if the user links directly to the tabcontent page instead of index.html.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...