以下代码似乎无法在IE中运行。在Chrome中,它仅在页面刷新几次后才起作用。有什么想法错了吗?感谢。
SCAN SHIPMENT:
<input type='text' name='scan_shipment' maxlength="30" id='scan_shipment'
maxlength="20" size='30' onkeypress="handleKeyPress(event,this.form)"/></td>
function handleKeyPress(e,form){
alert("test");
var key=e.keyCode || e.which;
if (key==13){
var age = document.getElementById('scan_shipment').value;
age = age.substring(1, age.length);
var appropiateTr = document.getElementById(age);
if(appropiateTr==null) {
var $messageDiv = $('#message'); // get the reference of the div
$messageDiv.show().html('<H1>Barcode not found in this Manifest</H1>');
// show and set the message
setTimeout(function(){ $messageDiv.hide().html('');}, 3000); // 3
seconds later, hide
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'error-beep.mp3');
audioElement.setAttribute('autoplay', 'autoplay');
audioElement.play();
$('#scan_shipment').val("");
return;
}
ajaxFunction();
}
}