Thursday, 22 October 2009

click Event Problem Firefox Solution

click Event in Firefox and Chrome doesn't work as expected, while it works perfectly with IE.I have a following Javascript code which was not working

document.getElementById('hlHome').click()
Where "hlHome" is ID of Home Link

Example: I have defined link like following

Following piece of code was working perfect with IE, but Firefox and Chrome didn't recognise this event.

Solution for Click Event Problem for Firefox, Chrome.
Wherever you are using click event as shown above replace that line with following.
window.location.href = document.getElementById('hlHome').href;