Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-28-2012, 07:30 AM   PM User | #1
moshelog
New to the CF scene

 
Join Date: Sep 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
moshelog is an unknown quantity at this point
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
moshelog is offline   Reply With Quote
Old 09-28-2012, 08:37 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,032
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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.
Philip M is offline   Reply With Quote
Old 09-28-2012, 03:03 PM   PM User | #3
moshelog
New to the CF scene

 
Join Date: Sep 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
moshelog is an unknown quantity at this point
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..
moshelog is offline   Reply With Quote
Old 09-28-2012, 03:21 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,032
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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";
}
__________________

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.

Last edited by Philip M; 09-28-2012 at 03:28 PM..
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
moshelog (09-28-2012)
Old 09-28-2012, 10:56 PM   PM User | #5
moshelog
New to the CF scene

 
Join Date: Sep 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
moshelog is an unknown quantity at this point
ok got it

Last edited by moshelog; 09-28-2012 at 11:06 PM..
moshelog is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:25 PM.


Advertisement
Log in to turn off these ads.