<body id="body" runat="server" onkeydown="return showKeyCode(event)">
Whenever a key is pressed, IE8 (or in compatibility mode) triggers an exception pointing to an issue in line x, which is related to the body tag. How can I resolve this? The JavaScript code seems to be working fine with IE compatibility mode (but not with Chrome). Additionally, the code is not functioning properly in IE and Firefox (it does not block F5 and Enter key).
--> Object expected
var version = navigator.appVersion;
function showKeyCode(e) {
var keycode = (window.event) ? event.keyCode : e.keyCode;
if ((version.indexOf('MSIE') != -1)) {
if (keycode == 13) {
event.keyCode = 0;
event.returnValue = false;
return false;
}
}
else {
if (keycode == 13) {
return false;
}
}
}
Another issue I am encountering involves a simple JavaScript code in IE and Firefox (works in Chrome):
Nothing happens & --> Object expected
<a onclick="ClearTextboxes();" title="Close" id="close" runat="server">Close</a>
....inside script tags:
function ClearTextboxes() {
document.getElementById('<%= txtbox_name.ClientID %>').value = '';
document.getElementById('<%= txtbox_email.ClientID %>').value = '';
document.getElementById('<%= txtbox_content.ClientID %>').value = '';
document.getElementById('<%= ResultMail.ClientID %>').style.display = 'none';
}