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)驗總結
- 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)試操作實例分析
相關文章
HTML5附件拖拽上傳drop & google.gears實現(xiàn)代碼
從gmail 的附件拖拽上傳,到網(wǎng)易郵箱的拖拽上傳,我們看到了html 5 為我們帶來了新的web體驗。2011-04-04JS生態(tài)系統(tǒng)加速Tailwind?CSS工作原理探究
這篇文章主要為大家介紹了JS?生態(tài)系統(tǒng)加速Tailwind?CSS使用及工作原理探究,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2024-01-01JavaScript中使用正則匹配多條,且獲取每條中的分組數(shù)據(jù)
該問題在使用Ajax遠程獲取某網(wǎng)頁數(shù)據(jù)時經(jīng)常遇見 如果目標頁面是XML,就好辦了,實用XMLDOM可以很輕松完成任務。2010-11-11