JavaScript - Event handler for one anchor tag being used in different installations

Asked By SP on 18-Oct-16 11:48 AM
Hey guys,

How do I use javascript / jQuery event handler for my html anchor.

The html anchor I have has a requirement to call onclick function in one installation, and same usercontrol is being used in another installation which doesn't have a onclick requirement.

I can do this with server code check like 

<% if Installation 1 %>
<a href="blahblah" onclick=dosomething>AnchorName </a>
<% else %>
<a href="blahblah">AnchorName </a>

But I don't want to use like this. Anyone has got any idea how I can do it with eventhandler?

Thanks,
Robbe Morris replied to SP on 19-Oct-16 08:49 AM
Do the installation check inside the function you are calling instead of conditionally writing your html.  Also, you'll want the href to be href="#" and the onclick to return false otherwise, your onclick will trigger navigation.