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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    redirect with image/cookie load

    I am aware of PHP redirect script such as this one:

    <?php
    /* Redirect browser */
    header("Location: http://theos.in/");
    /* Make sure that code below does not get executed when we redirect. */
    exit;
    ?>


    But I need a redirect script that will redirect only after an image is loaded.

    WHY I need this:
    I am trying to use an image pixel to do affiliate tracking and then redirect to a specific page on the advertiser's site (my affiliate link only goes to the advertiser's home page and I am promoting a specific product).

    Now that you understand WHY I need this, maybe you have a bright idea or two.

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    I don't think PHP could listen if the image has fully loaded. This could be done via Javascript:
    Code:
    <img src="..." alt="..." onload="location.href='http://theos.in/';">
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #3
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the reply... When I use this code, the image loads but I dont get redirect (in Firefox or IE):

    Code:
    <html><body><script type='text/javascript'>
    
    function Doredirect()
    {
    window.location = 'LANDINGPAGE.htm';
    }
    
    </script>
    
    <img onload='javascript:Doredirect()' src="TRACKING.htm" width="1" height="1" alt=" "> 
    </body>
    </html>
    Do you know why I'm not being redirected?

  • #4
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Quote Originally Posted by jargall View Post
    Code:
    <img onload='javascript:Doredirect()' src="TRACKING.htm" width="1" height="1" alt=" ">
    Do you know why I'm not being redirected?
    ...that only means the image has not been loaded.

    ...and I mean image:
    Code:
    <img onload='javascript:Doredirect()' src="TRACKING.htm" width="1" height="1" alt=" ">
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #5
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah, I see. hmm... Do you think there is a way to make this work? This is what I'm trying to do again:

    WHY I need this:
    I am trying to use an image pixel to do affiliate tracking and then redirect to a specific page on the advertiser's site (my affiliate link only goes to the advertiser's home page and I am promoting a specific product).
    I don't necessarily need the image to load. This was just one way of getting the cookie onto the visitor's computer. Any ideas for a cookie stuff/redirect?

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Use an onload tag in the <body> to change the location and put your image just after the <body> tag. This is not a server-side issue, so I'm going to move it to the JavaScript forum.


  •  

    Posting Permissions

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