[英]Javascript runtime error using IE11 on Win7: Unable to set property 'disabled' of undefined or null reference
I am currently working on some IE11 compatibility issues. 我目前正在处理某些IE11兼容性问题。 The code is fully functional in compatibility mode as it was previously optimize last for IE5. 该代码在兼容模式下具有完整的功能,因为它先前针对IE5进行了最后优化。
The affected code is as follows: 受影响的代码如下:
/*
* This function sets the specified button state in the repair processing form
*/
function setOperationButton(buttonId, disabledState, sourceImage, styleCursor)
{
var buttonElement = document.frmRepairProcessing.elements[buttonId];
var sourceRoot = '<%=helper.getApplicationURL()%>' + '/zimages/' + '<%=localeString%>' + '/';
buttonElement.disabled = disabledState;
buttonElement.src = sourceRoot + sourceImage;
buttonElement.style.cursor = styleCursor;
}
So I am thinking the code simply needs to be updated to use getElementById, but I am not quite sure how to implement the specific form. 因此,我认为只需更新代码即可使用getElementById,但是我不确定如何实现特定形式。
Please note: I have also tried document.forms().elements() and using .value as well. 请注意:我也尝试了document.forms()。elements()并也使用.value。
I believe it will be acceptable to use below code to obtain buttonElement: 我相信使用下面的代码来获取buttonElement是可以接受的:
function setOperationButton(buttonId, disabledState, sourceImage, styleCursor)
{
var buttonElement = document.getElementById(buttonId);
var sourceRoot = '<%=helper.getApplicationURL()%>' + '/zimages/' + '<%=localeString%>' + '/';
buttonElement.disabled = disabledState;
buttonElement.src = sourceRoot + sourceImage;
buttonElement.style.cursor = styleCursor;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.