Link to home
Start Free TrialLog in
Avatar of kimmie8000
kimmie8000Flag for United States of America

asked on

OnClick Event needs to fire first

To whom it may concern:

I have the following code:

function Charts_onclick() {

        window.location.href = "http://www.somelink";
        return true;

        }

<td><a href="redirect.ashx?url=http://www.AnotherLink?utm_source=landingpage_utm_medium=cpc_utm_campaign=Anatomical+Skeletal+System+LP1+Link6" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Models','','images/ACC_TopNav_Models_Ovr.gif',1)"><img src="images/ACC_TopNav_Models.gif" alt="Models" name="Models" width="113" height="33" border="0" id="Models" onclick="return Models_onclick('http://www.somelink')" /></a></td>

I don't want this to go to the href.  I need the onclick event to move the user to www.somelink.

I only want to record the Anotherlink in my redirect.ashx?  How do I make the onclick event work and not have the redirect happen.  This redirect has a bunch of special characters otherwise the a normal redirect would happen, but I have to record it to a database.
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Not Clear what are doing there is function and you are using url also ?
You posted a function called Charts_onclick and a link that calls Models_click - but nothing that calls Charts_onclick?

You can do this

<a href="...." onclick="Somefunction(); return false;" >

function SomeFunction() {
  // your code
  // no need to return anything here
}

or as you have it in which case you must return false from the function as mplungjan suggested above.