Q:

HTML automatically mapping href to root

I have an anchor tag with the href set as:
 <a href="$myfunction(param)$">; Click Here</a>

When I click on Click here, it redirects to http://mywebsite/$myfunction(1234).
This page obviously does not exist. How do I ensure that clicking on the above link does not map to the root? I would like it to call the javascript function.
Note: I cannot do this:
<a href="javascript:$myfunction(param)$">Click Here</a>. 

The reason is that we have a 3rd party crawler (no source code available) that searches for anchor tags on our page and picks up the href part for the link and fails if not found in the exact format $myfunction(param)$

A:

have you tried to invoke the onClick handler?
<a href="" onClick="myfunction(param)">; Click Here</a>

Another approach is the following

function MyFunction(param){
 alert(param);
}
(function() {
 var aElements = document.getElementsByTagName("a");
 var aList = Array.prototype.slice.call(aElements);
 aList.forEach(function(elem) {   
    var regex = /\$(.*?)\$/g;
   var result =regex.exec(elem.href);
 if (result != undefined && result.length > 0) {
  elem.onclick= function(){
    //executes function
  eval(result[result.length-1]);
    //prevents href action;
  return false;
    }
   }
 });
})();
<a href="$MyFunction('hello')$">I have a function</a>
<br/>
<a href="#home">I have a normal link</a>
<br/>
<a href="$MyFunction('world')$">I have another function</a>

