Forum Moderators: open

Message Too Old, No Replies

Spider friendly JS linking...

...with 2 onclick events

         

Adam_C

1:43 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



I'm working on a clients site, which has been set up to channel traffic to another website as part of an *involved* marketing strategy.

They are tracking the clickouts with the following bit of code:

<a href="http://www.clientssite.com/redirect.jsp?url=http://www.widgets.com" onclick="

return confirm('You will now leave this site and goto widgets.com. We need this message for legal reasons ');"

>link</a>

There are certain legal issues which mean that there must be a warning box pop-up telling the user that they are leaving the site when they click the link, so they're using a js confirm box.

As the ultimate goal of this site is to funnel users to another site, I suggested that in order to promote the target site they would do well to make the redirect link spiderable (to pass PageRank, etc.), so I've tried to implement something like was dicussed here [webmasterworld.com] so spiders follow the href and browser the onclick:

<a href="http://www.widgets.com" onclick="

return confirm('You will now leave this site and goto widgets.com. We need this message for legal reasons ');

window.top.location.href('http://www.clientssite.com/redirect.jsp?url=http://www.widgets.com');

return false;

">link</a>

... but I can't get it to work properly. Having the two onclick functions seems to be causing a problem. Can anyone see what I should be doing?

Cheers

johannes

4:22 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



Try this:

<a href="http://www.widgets.com" onclick="

confirm('You will now leave this site and goto widgets.com. We need this message for legal reasons ');

window.top.location=('http://www.clientssite.com/redirect.jsp?url=http://www.widgets.com');

return false;

">link</a>

Adam_C

4:33 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



looks like you've smashed it

cheers!

Adam_C

4:39 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



Sorry - spoke too soon.

The "Cancel" doesn't work in the Confirm box. Goes through to the URL in the window.top.location=

johannes

6:09 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



How about?

<a href="http://www.widgets.com" onclick="

if(confirm('You will now leave this site and goto widgets.com. We need this message for legal reasons '))

window.top.location=('http://www.clientssite.com/redirect.jsp?url=http://www.widgets.com');

return false;

">link</a>

Adam_C

9:16 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



Bingo!

Thanks a lot.