问题
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