View Full Version : create order links out of a specified group of links

09-28-2012, 07:30 AM
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

Philip M
09-28-2012, 08:37 AM
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.

09-28-2012, 03:03 PM
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 .

Philip M
09-28-2012, 03:21 PM
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.

var now = new Date().getSeconds();
if (now %2 == 0) {
var redirecturl = "link1";
else {
var redirecturl = "link2";

09-28-2012, 10:56 PM
ok got it