[英]Javascript runtime error using IE11 on Win7: Unable to set property 'disabled' of undefined or null reference
我目前正在处理某些IE11兼容性问题。 该代码在兼容模式下具有完整的功能,因为它先前针对IE5进行了最后优化。
受影响的代码如下:
/*
* 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;
}
因此,我认为只需更新代码即可使用getElementById,但是我不确定如何实现特定形式。
请注意:我也尝试了document.forms()。elements()并也使用.value。
我相信使用下面的代码来获取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.