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 Coder
    Join Date
    Apr 2008
    Location
    Atlanta, GA
    Posts
    23
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Cool Redirect Iframe when loaded directly

    I'm using an Iframe on 1 page, without problems, however I like to built in some "security", to make sure the user sees what I want them to see....
    When user goes directly to the iframe source, I like to have that page redirect to the page that contains the Iframe,

    Example:
    page 123.xxx contains the iframe. In this iframe it loads page 456.xxx

    Now when a user goes directly to 456.xx, I like that page to redirect automatically, so 123.xxx will be loaded.
    Exception:
    As some users might not be able to view iframes, I show the user a link that I have in the iframe code, to "click here" and this will open the page 456.xxx in a new window.

    I was maybe thinking of using the referral link...
    Something like: If referral link is 123.xxx, show content, else redirect to 123.xxx
    Anyone ideas on how to accomplish this?

  • #2
    New Coder
    Join Date
    Apr 2008
    Location
    Atlanta, GA
    Posts
    23
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Thumbs up

    With javascript placed in 456.xxx this works:

    <script language="JavaScript"><!--
    var ref = document.referrer;
    if (ref.indexOf('www.myurl.com') != -1)
    {}
    else
    window.location.href = 'http://www.myurl.com/123.xxx';
    //--></script>


  •  

    Tags for this Thread

    Posting Permissions

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