About this site
Links to us
This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Generated 20:01:34 on Aug 9, 2020
Answer: Indeed there are these two possiblities as shown in the box below.
The problem with the second solution is that your browser will jump to the top of the page (href=#).
If onclick returns false, the browser never even looks at the href attribute, and so it is not followed. Thus you should add ; return false; to the onclick event handler.
The third example shows how it this looks like.
<!-- two possibilities to link an event handler to a clickable link -->
<a href="#" onclick="fillform()">Pre-Fill</a>
<!-- this is the best way to do it: -->
<a href="#" onclick="fillform(); return false;">Pre-Fill</a>
<a href="myform.php?fillform=1" onclick="fillform(); return false;">Pre-Fill</a>
|Most recent comments