IE10 only given me an 'Unable to evaluate expression' error when changing style

好久不见. 提交于 2020-01-02 14:33:30

问题


I have the following javascript function to hide an HTML tag:

function object_Hide_obj(objectId) {

    var objname=document.getElementById(objectId);
    if (objname) {
        objname.style.display = "none";
    }
}

I have an instance where objname is a valid HTML <tr> tag. In IE10 only (works fine on IE9, IE11, Chrome, and Safari) I get a weird error on objname.style.display = "none";. When I Try to evaluate this in the console I get a 'Unable to evaluate expression' error, and the the browser just crashes when it reaches that line. If I debug, sometimes this doesn't happen. Does anyone know why?


回答1:


Its a bug in IE10 try to install this update KB2884101 first

function object_Hide_obj(objectId) {
var objname=document.getElementById(objectId);
if (objname) {
    objname.style.display = "none";
}

}

Blockquote

Place a html5 tag start of your page and try it

      <!DOCTYPE html>
      <table>
        <tr id="id0">
            <td>
                line 0
                <input type="button" onclick="object_Hide_obj('id1')" value="Hide line 1">
            </td>
        </tr>
        <tr id="id1">
            <td>
                line 1
            </td>
        </tr>

best of luck



来源:https://stackoverflow.com/questions/25769763/ie10-only-given-me-an-unable-to-evaluate-expression-error-when-changing-style

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!