Javascript 學習筆記 錯誤處理
更新時間:2009年07月30日 21:41:04 作者:
Javascript學習筆記:錯誤處理.
Java代碼
<html>
<head>
<title>javascript</title>
<script type="text/javascript">
function test(inVal){
try{
inVal=inVal.toUpperCase();
}catch(error){
alert("An exception has occurred.Error was:\n\n"+error.message);
}
}
</script>
</head>
<body>
<input type="button" value="Test" onclick="test(null);">
</body>
</html>
<html>
<head>
<title>javascript</title>
<script type="text/javascript">
function test(inVal){
try{
inVal=inVal.toUpperCase();
}catch(error){
alert("An exception has occurred.Error was:\n\n"+error.message);
}
}
</script>
</head>
<body>
<input type="button" value="Test" onclick="test(null);">
</body>
</html>
利用firefox的firebug來調(diào)bug
引用
<html>
<head>
<title>javascript</title>
<script type="text/javascript">
function test(){
var a=0;
console.log("checkpoint 1");
a=a+1;
console.log("checkpoint 2");
a=a-1;
console.log("checkpoint 3");
a=a.toLowerCase();
console.log("checkpoint 4");
}
</script>
</head>
<body>
<input type="button" value="Test" onclick="test(null);">
</body>
</html>
在IE中可以添加一個方法
引用
function Console(){
this.log=function(inText){
alert(inText);
}
}
var console=new Console();
復制代碼 代碼如下:
<html>
<head>
<title>javascript</title>
<script type="text/javascript">
function test(inVal){
try{
inVal=inVal.toUpperCase();
}catch(error){
alert("An exception has occurred.Error was:\n\n"+error.message);
}
}
</script>
</head>
<body>
<input type="button" value="Test" onclick="test(null);">
</body>
</html>
復制代碼 代碼如下:
<html>
<head>
<title>javascript</title>
<script type="text/javascript">
function test(inVal){
try{
inVal=inVal.toUpperCase();
}catch(error){
alert("An exception has occurred.Error was:\n\n"+error.message);
}
}
</script>
</head>
<body>
<input type="button" value="Test" onclick="test(null);">
</body>
</html>
利用firefox的firebug來調(diào)bug
引用
復制代碼 代碼如下:
<html>
<head>
<title>javascript</title>
<script type="text/javascript">
function test(){
var a=0;
console.log("checkpoint 1");
a=a+1;
console.log("checkpoint 2");
a=a-1;
console.log("checkpoint 3");
a=a.toLowerCase();
console.log("checkpoint 4");
}
</script>
</head>
<body>
<input type="button" value="Test" onclick="test(null);">
</body>
</html>
在IE中可以添加一個方法
引用
復制代碼 代碼如下:
function Console(){
this.log=function(inText){
alert(inText);
}
}
var console=new Console();
您可能感興趣的文章:
- JavaScript高級程序設計 錯誤處理與調(diào)試學習筆記
- JavaScript 錯誤處理與調(diào)試經(jīng)驗總結(jié)
- Javascript 錯誤處理的幾種方法
- JavaScript錯誤處理
- 深入分析javascript中的錯誤處理機制
- 全面了解javascript中的錯誤處理機制
- 最佳的JavaScript錯誤處理實踐
- 使用Chrome調(diào)試JavaScript的斷點設置和調(diào)試技巧
- js調(diào)試工具Console命令詳解
- js調(diào)試工具console.log()方法查看js代碼的執(zhí)行情況
- javascript代碼調(diào)試之console.log 用法圖文詳解
- JS錯誤處理與調(diào)試操作實例分析
相關文章
微信小程序?qū)崿F(xiàn)跳轉(zhuǎn)的幾種方式總結(jié)(推薦)
這篇文章主要介紹了微信小程序跳轉(zhuǎn)方式,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-04-04
Auntion-TableSort javascript類文件
Auntion-TableSort javascript類文件...2007-11-11

