Results 1 to 3 of 3

Thread: Lyteframe: Check if page is loaded direct?

  1. #1
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Lyteframe: Check if page is loaded direct?

    I'm using lytebox/lyteframe to open sub-pages and very nice it is too but I'm finding that visitors are reaching the sub-pages directly from search engine results and, obviously the sub-pages lack navigation to the rest of the site which I would like visitors to see.
    Now I could always stop search engines from indexing the sub-pages using robots.txt but I don't want to do that as it would loose me visitors so what I would like to do is detect if a page is loaded in a lyteframe or has been loaded directly then, if direct, redirect visitors to the index page and my html/javascript/etc. simply isn't up to it!
    If that's not a possibility, is there a way to have a message appear on the page (or as a pop-up) only if the page isn't loaded in a lyteframe?
    Any ideas would be greatly appreciated.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,000
    Thanks
    44
    Thanked 3,198 Times in 3,160 Posts
    Blog Entries
    12

    Default

    On the sub-pages put:

    Code:
    <script type="text/javascript">
    if(top.location.href === location.href)
    	location.replace('/');
    </script>
    That's assuming the index page is in the root of the domain and has a name like index.htm, or index.html, etc. that makes it the default page. If in doubt, you may use the absolute path to the page you want to redirect to, ex:

    Code:
    <script type="text/javascript">
    if(top.location.href === location.href)
    	location.replace('http:/www.mydomain.com/index.html');
    </script>
    But the relative path or the network path (as in the first code block) is preferred for compatibility reasons.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    blackfive (04-13-2011)

  4. #3
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I'll try that when I get back to my PC next week. Many thanks.
    EDIT.....
    Again, many thanks. Works an absolute treat. Just what I needed to do!
    I'll know where to come the next time I get stuck.
    Last edited by blackfive; 04-13-2011 at 04:09 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •