So meanwhile working with HTML, I was trying to create an Anchor with a href defined but the link should NOT work. Click the following link,
As you can see the above link should redirect this page to Google, but it is NOT redirecting it. OK now try to open the link in a new Tab (if you are using a borwser which has tabbed browsing support, i.e. Ctrl+Click). This time it should work. Here is the HTML,
<a href="http://www.google.com" onclick="return false;">Google</a>
As you can see in above "onclick" event we have executed a little javascript which returns false. This is the statement which is suppressing the default behaviour of anchor. Some sites handle it like this,
<a href="javascript:void(0);" onclick="alert('You Clicked the Link');">Google</a>
1 comment:
Post a Comment