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

    create order links out of a specified group of links

    i want to have same code like this - > http://www.javascriptkit.com/javatutors/random2.shtml

    but not randomly
    i have only 2 links

    so on first click it will go to first link
    seocnd click it will go to second link
    3rd click it will go to first link again
    and so on ....


    thx in advance
    moshe lugasi

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,145
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    You cannot do that as if the page redirects to a link it is lost and the new page takes its place. You could only remember which link was last chosen by using a cookie.

    If you have only two links simply show them in your page. Random selections often only serve to annoy the user.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    i think i didnt explaind my self well
    and u misunderstood me .
    im sure it can be done

    i have a website , in this website there is "click here" button that if the visitor clicks on it he is directed to some kind of affiliate program and he can signup under my link .

    what i wish is when the second person that visit my website and click on that button it will direct him to my friend's link affiliate program .

    i want to share with my friend the signups 50% 50%

    maby we can do it with counter ? and when its double number direct him to first link and when its not direct him to second link ?

    sorry about my english .
    Last edited by moshelog; 09-28-2012 at 03:06 PM.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,145
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    No, you cannot do that with Javascript. You would need server-side coding if you insist on alternate redirects. The nearest you could do is redirect to one site if the time in seconds was odd, and to the other if the time in seconds was even. That would be effectively the same thing taken over a period and result in a 50/50 division.


    Code:
    var now = new Date().getSeconds();
    if (now %2 == 0) {
    var redirecturl = "link1";
    }
    else {
    var redirecturl = "link2";
    }
    Last edited by Philip M; 09-28-2012 at 03:28 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • Users who have thanked Philip M for this post:

    moshelog (09-28-2012)

  • #5
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    ok got it
    Last edited by moshelog; 09-28-2012 at 11:06 PM.


  •  

    Posting Permissions

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