Internet Explorer 11中的JavaScript错误
我有一个表单页面,可以从弹出窗口向数据库提交数据。我为提交数据添加了一个禁用的按钮js。它在ie11上不起作用,但在其他浏览器上效果很好Internet Explorer 11中的JavaScript错误,javascript,c#,asp.net,internet-explorer,internet-explorer-11,Javascript,C#,Asp.net,Internet Explorer,Internet Explorer 11,我有一个表单页面,可以从弹出窗口向数据库提交数据。我为提交数据添加了一个禁用的按钮js。它在ie11上不起作用,但在其他浏览器上效果很好 <script language="javascript" type="text/javascript"> // disables the button specified and sets its style to a disabled "look". function disableButtonOnClick(oButton
<script language="javascript" type="text/javascript">
// disables the button specified and sets its style to a disabled "look".
function disableButtonOnClick(oButton, sButtonText, sCssClass)
{
// set button to disabled so you can't click on it.
oButton.disabled = true;
// change the text of the button.
oButton.value = sButtonText;
// IE uses className for the css property.
oButton.setAttribute('className', sCssClass);
// Firefox, Safari use class for the css property.
oButton.setAttribute('class', sCssClass);
}
</script>
//禁用指定的按钮并将其样式设置为禁用的“外观”。
函数DisableButtonNonclick(oButton、sButtonText、sCssClass)
{
//将按钮设置为禁用,这样您就不能单击它。
oButton.disabled=true;
//更改按钮的文本。
oButton.value=sbuttonext;
//IE使用className作为css属性。
setAttribute('className',sCssClass);
//Firefox、Safari为css属性使用类。
setAttribute('class',sCssClass);
}
尝试下面的代码
if((navigator.userAgent.indexOf("MSIE") != -1 )
oButton.setAttribute('className', sCssClass);
else
oButton.setAttribute('class', sCssClass);
函数disableButtonClick(oButton,sButtonText,sCssClass){oButton.disabled=true;//更改按钮的文本。oButton.value=sButtonText;//IE使用css属性的类名。oButton.setAttribute('className',sCssClass);//Firefox,Safari为css属性使用类。oButton.setAttribute('class',sCssClass);}Avyy-lmao,我将把它添加到问题中。但与脚本无关。我猜它有一些浏览器问题。在IE上转到“设置->Internet选项->高级->浏览->禁用脚本调试(Internet Explorer)”并取消选中该选项。如果遇到javascript错误,IE将在错误发生时中断,您可以打开调试窗口。您将能够查明错误和遇到错误的行号。为什么要使用
setAttribute
而不是直接设置属性?