Clicking on my anchor tag, shown below, does not hide the notify-parent div. The notify-parent div is correctly hidden in IE7 and IE8 but not in Firefox.
<script type="text/javascript">
function checkClick(e) {
var obj = e.srcElement;
if (obj.id != "notify-parent")
document.getElementById('notify-parent').style.display = 'none';
return;
}
</script>
<div id="notify-parent" style="padding-bottom: 10px; margin-top: -10px;">
<table width="800">
<tr>
<td>
</td>
</tr>
<tr>
<td align="center">
<div id="notify-container">
<table style="padding: 10 10 10 10">
<tr>
<td>
</td>
<td>
</td>
<td align="right">
<a class="close-notify" onclick="checkClick(event);return false" title="dismiss this notification">
×</a>
</td>
</tr>
<tr>
<td>
</td>
<td>
A message goes here
</td>
</tr>
<td>
</td>
</table>
</div>
</td>
</tr>
</table>
</div>
I tried adding href="#" but that didn’t solve the issue.
What am I doing wrong?
There is no srcElement on the event object in firefox. I can visually see this in firebug. You might consider using target. You can also use a javascript framework that will standardize this across browsers. Can’t remember off hand, but I’m sure JQuery does this.
Firebug is awesome btw. I set a breakpoint and included a screenshot for you so that you can see exactly what is in that event object on firefox.
Also see https://developer.mozilla.org/en/DOM/event as a reference.