Posts

Showing posts from March, 2010

Proper way to have an anchor tag with onclick event

Anchor tags are one of the most common HTML tags used in pages. If the user right clicks on the anchor tag he/she will be provided with an option of 'Open in new Window/Open in new Tab'. This will happen only if the anchor has href attribute.

Sometimes it is required to do some other action (like making ajax request) on click of the anchor link and also provide the right click option for the same anchor.

Natural practice by web developers.

<a href="javascript:void(0);" onclick="alert('i am here');">Click Me! </a>

Click Me without link for anchor!


Correct way to add anchor tags without losing anchor properties.

<a href="http://www.blogger.com/amareswar.blogspot.com" onclick="alert('i am here'); return false;">Click Me! </a>

Click Me!

In the above link, you can observe that the user can right click on go to the respective link and onclick will do the custom action provided by the developer.

My Son my life

Image
Life changed a lot after my son 'Harshith' came into my life. It is the feeling that you can nerver forget. I am enjoying the most happiest phase of my life. Missing him a lot as he is staying away from me with her mother. Hoping to be with him as soon as possible.