How to have an element invoke a javascript on selection, instead of going to a new URL ?

Bharathi Cherukuri
Posted by Bharathi Cherukuri under JavaScript category on | Points: 40 | Views : 1256
To have an element invoke a javascript on selection, instead of going to a new URL, below is an example for it.

Example:


<script type="text/javascript">
function pseudoHitMe() {
alert("Ouch!");
}
</script>
<a href="javascript:pseudoHitMe()">hit me</a>

Comments or Responses

Login to post response