[英]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.