Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Kidderminster...UK
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Redirect to home page script needed

    I run a site that contains pages used by news gathering sites such as Newsnow and Moreover which are in turn used as a newsfeed on other sites.

    The problem is that my site uses frames and the pages that Newsnow etc access are seen as individual pages by other users.
    That person then reads the page in question and then closes it without ever going to my index page.

    So, I'm looking for a script that will send them to my index page (site) when they close the page they are viewing.

    I have tried putting a link from each page to my index page but this all depends on that link being clicked.

    I have used a snippet of code that does work when the page is seen individually:

    <script type='text/javascript'>
    function openWindow() {
    window.open("http://www.harriers-online.co.uk",'');
    }
    </script>
    <body onunLoad="openWindow()">

    but when that page is viewed from within the frameset and the user then either uses the back button on the toolbar or clicks on another page on my menu it then opens up my site in a new window and also goes to the page you clicked on in the page that loaded second.

    I'm sorry if this seems all a bit long winded and poorly explained but it's the only way I can describe the problem.

    I've set up a page on the site to demonstrate the problem.

    First click here to go to a stand alone page

    Test page

    Close that window and my site should open up in a new window.
    Scroll down the menu to the bottom and click on the test link and the click on one of the links at the top of the menu or on the back button on your toolbar.

    This should demonstrate the problem and hopefully help some kind soul to come up with an answer to my question.

    Thanks
    Phil.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Mumbai, India
    Posts
    218
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Do you want that if a user visits a frame of your page, you want the user to go to the main page in which the frame is located?

    I think this should work:

    <script>
    // This script must be used in all your frame pages
    var parentSite="http://www.yourMainSite.com"; // Site to redirect
    function checkFrame()
    {
    if((parent.location)==(window.location))
    {
    // do whatever here
    parent.location.replace(parentSite);
    }
    }
    </script>

    <body onload="checkFrame()">

    Is this fine?


  •  

    Posting Permissions

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