Basic JavaScript Question:
Download Questions PDF

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

Answer:

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

Download JavaScript Interview Questions And Answers PDF

Previous QuestionNext Question
How to Add new elements dynamically?How to have the status line update when the mouse goes over a link (The support of the status line is sporadic)?