<script language="JavaScript">
<!--
var s = "a=(6-(7*8-4)"function check(str)
{
try
{
eval(str);
return true;
}
catch(e)
{
alert(e.description);
return false;
}
}check(s);//-->
</script>
<!--
var s = "a=(6-(7*8-4)"function check(str)
{
try
{
eval(str);
return true;
}
catch(e)
{
alert(e.description);
return false;
}
}check(s);//-->
</script>
var s = "a=(6-(7*8-4)";
function check(exp)
{
window.oldOnError = window.onerror;
window.onerror = function (err)
{
alert("你的算术式 "+ exp +" 是错误的!")
return true;
};
eval(exp);
window.onerror = window.oldOnError;
}
check(s);
</script>