<div class="codetitle"> <span><a style="CURSOR: pointer" data="94890" class="copybut" id="copybut94890" onclick="doCopy('code94890')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code94890"> <br><script type="text/javascript"> <BR>//用於在friefox中調試用console.log("hello"); <BR>/**函數測試(名稱){ <BR>console.log(名稱); <BR>} <BR>測試(「你好世界」);**/ <br><br>//調試的技巧<BR>function showLog(message) { <BR> console.log(message); <BR>console.info(message); <BR>console.warn(message); <BR>console.error(message); <BR>console.debug(message); <BR> } <BR>function test(name) { <BR>showLog(name); <BR>} <BR>test("hello"); <br><br></script> <br> </div> <br><br> <div class="codetitle"><span> <a style="CURSOR: pointer" data="86605" class="copybut" id="copybut86605" onclick="doCopy('code86605')">偵錯範例<u></u></a></span></div>複製程式碼<div class="codebody" id="code86605"> <br><br> 程式碼如下:<br><br> <br>BR> <br> <br> <br> <br><meta http- equiv="Content-Type" content="text/html; charset=UTF-8"> <br><title>Insert title here</title> <br><script type="text/javascript"> <BR> <BR>function method() { <br>var result = 0; <br>for(var i = 0; i < 10; i ) { <BR>result =i; <BR>} <BR>document.getElementById ("id1").innerHTML = result; <BR>} <BR><BR><BR></script> <br> </div> <input type="button" value="click" onclick="method()"> <div id="id1"></div>