Javascript 學(xué)習(xí)筆記 錯(cuò)誤處理
更新時(shí)間:2009年07月30日 21:41:04 作者:
Javascript學(xué)習(xí)筆記:錯(cuò)誤處理.
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來(lái)調(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中可以添加一個(gè)方法
引用
function Console(){
this.log=function(inText){
alert(inText);
}
}
var console=new Console();
復(fù)制代碼 代碼如下:
<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>
復(fù)制代碼 代碼如下:
<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來(lái)調(diào)bug
引用
復(fù)制代碼 代碼如下:
<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中可以添加一個(gè)方法
引用
復(fù)制代碼 代碼如下:
function Console(){
this.log=function(inText){
alert(inText);
}
}
var console=new Console();
您可能感興趣的文章:
- JavaScript高級(jí)程序設(shè)計(jì) 錯(cuò)誤處理與調(diào)試學(xué)習(xí)筆記
- JavaScript 錯(cuò)誤處理與調(diào)試經(jīng)驗(yàn)總結(jié)
- Javascript 錯(cuò)誤處理的幾種方法
- JavaScript錯(cuò)誤處理
- 深入分析javascript中的錯(cuò)誤處理機(jī)制
- 全面了解javascript中的錯(cuò)誤處理機(jī)制
- 最佳的JavaScript錯(cuò)誤處理實(shí)踐
- 使用Chrome調(diào)試JavaScript的斷點(diǎn)設(shè)置和調(diào)試技巧
- js調(diào)試工具Console命令詳解
- js調(diào)試工具console.log()方法查看js代碼的執(zhí)行情況
- javascript代碼調(diào)試之console.log 用法圖文詳解
- JS錯(cuò)誤處理與調(diào)試操作實(shí)例分析
相關(guān)文章
JavaScript代碼模擬鼠標(biāo)自動(dòng)點(diǎn)擊事件示例
這篇文章主要介紹了JavaScript代碼模擬鼠標(biāo)自動(dòng)點(diǎn)擊事件示例,文章通過(guò)示例代碼和運(yùn)行效果圖介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08HTML5附件拖拽上傳drop & google.gears實(shí)現(xiàn)代碼
從gmail 的附件拖拽上傳,到網(wǎng)易郵箱的拖拽上傳,我們看到了html 5 為我們帶來(lái)了新的web體驗(yàn)。2011-04-04JS生態(tài)系統(tǒng)加速Tailwind?CSS工作原理探究
這篇文章主要為大家介紹了JS?生態(tài)系統(tǒng)加速Tailwind?CSS使用及工作原理探究,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2024-01-01JavaScript中使用正則匹配多條,且獲取每條中的分組數(shù)據(jù)
該問(wèn)題在使用Ajax遠(yuǎn)程獲取某網(wǎng)頁(yè)數(shù)據(jù)時(shí)經(jīng)常遇見(jiàn) 如果目標(biāo)頁(yè)面是XML,就好辦了,實(shí)用XMLDOM可以很輕松完成任務(wù)。2010-11-11微信小程序?qū)崿F(xiàn)選項(xiàng)卡的方法
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)選項(xiàng)卡的方法,利用swiper組件實(shí)現(xiàn)選項(xiàng)卡功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-07-07JS實(shí)現(xiàn)n秒后自動(dòng)跳轉(zhuǎn)的兩種方法
這篇文章主要為大家詳細(xì)介紹了JS實(shí)現(xiàn)n秒后自動(dòng)跳轉(zhuǎn)的兩種方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-07-07JS正則表達(dá)式大全(整理詳細(xì)且實(shí)用)
JS正則表達(dá)式大全(整理詳細(xì)且實(shí)用)。需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2013-11-11