Forum Moderators: open

Message Too Old, No Replies

cookie and link timing problem

         

Seo_Prof

3:06 pm on Jul 27, 2006 (gmt 0)

10+ Year Member



Hi there,

Im trying to call a javascript function which includes dynamically a tracking image when someone clicking a link and then moving to that link:

<a onclick="track(12345);" href="http://www.test.com/">

and here are parts of my javascript functions:

function track(id){
ajax.requestFile = 'track.php?id='+id;
ajax.onCompletion = showContent;
ajax.runAJAX();
}

function showContent(){
contentObj.innerHTML = ajax.response;
}

the track function calls a php script which includes a tracking image in a div so the visitor will get a cookie. The Problem is that the visitor will be moved to the new page before the cookie is set.
Do you have any idea how I can let the script wait till the cookie is set?

thanks

RonPK

10:48 am on Jul 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello and welcome,

Basically the setup should be like this:

<a href="bla.html" onclick="return track(12345)">

function track(id) { 
// do your stuff, like set cookie
return true;
}

If the function returns

false
, the browser will not jump to the page set in href.