惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
V
Vulnerabilities – Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
Spread Privacy
Spread Privacy
P
Proofpoint News Feed
AWS News Blog
AWS News Blog
S
Securelist
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
T
Troy Hunt's Blog
SecWiki News
SecWiki News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Security Latest
Security Latest
C
Cyber Attacks, Cyber Crime and Cyber Security
AI
AI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Stack Overflow Blog
Stack Overflow Blog
I
Intezer
I
InfoQ
Attack and Defense Labs
Attack and Defense Labs
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
The Exploit Database - CXSecurity.com
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
N
News | PayPal Newsroom
云风的 BLOG
云风的 BLOG
S
Secure Thoughts
T
The Blog of Author Tim Ferriss
Martin Fowler
Martin Fowler
L
LINUX DO - 最新话题
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
A
About on SuperTechFans
Hacker News - Newest:
Hacker News - Newest: "LLM"
TaoSecurity Blog
TaoSecurity Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
L
LangChain Blog
MyScale Blog
MyScale Blog
Recent Announcements
Recent Announcements
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Engineering at Meta
Engineering at Meta
C
Cybersecurity and Infrastructure Security Agency CISA
Y
Y Combinator Blog
L
Lohrmann on Cybersecurity
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog

博客园 - asheng

JavaScript UI选型及Jquery EasyUI使用经验谈 云计算风险识别 五年之痒 敏捷软件开发 嫁给程序员吧!!! Cute Editor for .NET v6.4 Java与.NET的WebServices相互调用 用户体验5大要素 【转】LINQ To XML 入门(3) 【转】LINQ To XML 入门(2) 【转】LINQ To XML 入门(1) 学写Windows Service 微软发布ASP.NET MVC框架1.0正式版 Web定时任务 CSS分类编写方法 JS中错误处理(1) Log4Net OWC画图表 - asheng - 博客园 好员工为什么会变坏
JS中错误处理(2)
asheng · 2009-02-05 · via 博客园 - asheng

throw语句
使用throw语句可以生成一个例外(exception)。结合 try…catch 使用throw语句可以控制程序流程,并生成准确地出错信息。
语法
throw(exception)
其中exception可以是字符串,整数,布尔值,或一个对象。
注意 throw 为小写字母。 使用大写字母会造成 JavaScript 出错!
例1
以下例子根据变量x的值进行不同的动作。 如果x值大于10或小于0,就会抛出一个错误。出错会被 catch 参数捕获,显示适当的出错信息:

<html> 
<head> 
<script type="text/javascript"> 
onerror
=handleErr 
var txt="" 
function handleErr(msg,url,l) 

txt
="There was an error on this page.\n\n" 
txt
+="Error: " + msg + "\n" 
txt
+="URL: " + url + "\n" 
txt
+="Line: " + l + "\n\n" 
txt
+="Click OK to continue.\n\n" 
alert(txt) 
return true 
}
function message() 

adddlert(
"Welcome guest!"

</script> 
</head><body> 
<input type="button" value="View message" onclick="message()" /> 
</body> </html> 

//****************************************
  by: Amen cnblogs博客  转载请注明出处
//****************************************