Monday, February 22, 2010

Cross browser object check

HTML

<input type="button" onclick="handleViewHTMLContent(event);" id="button1" value="View Content" style="float: right;">

<input type="button" onclick="handleViewHTMLContent(event);" id="button2" value="View Content" style="float: right;">


Javascript

...
function handleViewHTMLContent(event) {
var button = event.srcElement || event.currentTarget; //IE : Firefox
alert(button.id);
}