Rather than display the error details, the entire javascript is just not displayed. The subscripts and superscripts aren't displayed either!开发者_运维知识库
try
{
document.write("<p>Fontsize: " + txt.fontsize(6px) + "</p>");
}
catch(err)
{
document.write("Error details: " + err);
}
document.write("<p>Subscript: " + txt.sub() + "</p>");
document.write("<p>Superscript: " + txt.sup() + "</p>");
6px
is invalid syntax.
Therefore, the entire script is not executed. (since it can't be parsed)
catch
blocks catch runtime errors in your script.
If the script contains invalid syntax, the Javascript interpreter will throw out the entire script, because it makes no sense.
It will not try to recover whatever it can make sense out of.
精彩评论