js 重新学习笔记( 三 ) 特殊字符 , trycatch1, ? ? js 捕捉错误 ?用 try .... catch?noerror ?事件 , 老式
js 重新学习笔记( 三 ) 特殊字符 , try catch
1, ? ? js 捕捉错误 ?
用 try .... catch?
noerror ?事件 , 老式的捕获错误的处理方式.
? ? ? ? ? ?注意:chrome、opera 和 safari 浏览器不支持 onerror 事件。
2, ? ?throw( exception ) ?
? ? ? ? exception 可以是 字符串, 数值 ,逻辑值 , 或对象
?
? var x=prompt("Enter a number between 0 and 10:","")
? ? ?现在 JavaScript 就可以输出正确的文本字符串了:We are the so-called "Vikings" from the north。
? ??document.write ("You
\&me are singing!")??
? ? 上面的例子会产生以下输出:
You & me are singing!
?下面的表格列出了其余的特殊字符,这些特殊字符都可以使用反斜杠来添加到文本字符串中:
下面的表格列出了其余的特殊字符,这些特殊字符都可以使用反斜杠来添加到文本字符串中:
代码输出\'单引号"双引号\&和号\\反斜杠\n换行符\r回车符\t制表符\b退格符\f换页符
