首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

帮忙给调试一下js,另求教调试工具和方法,书籍!该如何解决

2012-06-01 
帮忙给调试一下js,另求教调试工具和方法,书籍!先来代码displayAttreviations.jsJScript code// JavaScript

帮忙给调试一下js,另求教调试工具和方法,书籍!
先来代码
displayAttreviations.js

JScript code
// JavaScript Documentfunction displayAbbreviations(){    if(!document.getElementsByTagName||!document.createElement||!document.createTextNode) return false;    //get abbr    var abbreviations = document.getElementsByTagName("abbr");    if(abbreviations.length<1) return false;    var defs = new Array();    //do all abbr    for(var i=0; i<abbreviations.length;i++){        var current_abbr = abbreviations[i];        var defition = current_abbr.getAttribute("title");        var key = current_abbr.lastChild.nodeValue;        defs[key] = defition;        }        //create defition list        var dlist = document.createElement("dl");        //do all defition        for(key in defs) {            var defition = defs[key];            var dtitle = document.createElement("dt");            var dtitle_text = document.createTextNode(key);            dtitle.appendChild(dtitle_text);            //create defition description            var ddesc = document.createElement("dd");            var ddesc_text = document.createTextNode(defition);            ddesc.appendChild(ddesc_text);            //add them to defition list            dlist.appendChild(dtitle);            dlist.appendChild(ddesc);            }            //create title            var header = document.createElement("h2");            var header_text = document.createTextNode("Abbreviations");            header.appendChild(header_text);            //add title to document body            document.getElementsByTagName("body")[0].appendChlid(header);            //add defition list to document body            document.getElementsByTagName("body")[0].appendChlid(dlist);}addLoadEvent(displayAbbreviations);

addLoadEvent.js
JScript code
// JavaScript Documentfunction addLoadEvent(func){    var oldonload = window.onload;    if(typeof window.onload!='function'){        window.onload = func;    }else{        window.onload = function(){            oldonload();            func();        }    }}


explanation.html
HTML code
<!DOCTYPE html><html lang="en"><head><meta charset="uft-8" /><title>Explaining the Document Object Model</title><link rel="stylesheet" media="screen" href="styles/typography.css" /></head><body>  <h1>What is the Document Object Model?</h1>    <p>The <abbr title="World Wide Web Consortium">W3C</abbr> defines the <abbr title="Document Object Model">DOM</abbr> as:</p>    <blockquote cite="http://www.w3.org/DOM/"><p> A platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content,structure and style of documents.</p></blockquote>     <p>It is an <abbr title="Application Programming Interface">API</abbr> that can be used to navigate <abbr title="HyperText Markup Language">HTML</abbr> and <abbr title="eXtensible Markup Language">XML</abbr> documents.</p>   <script type="text/javascript" src="scripts/addLoadEvent.js"></script>   <script type="text/javascript" src="scripts/displayAbbreviations.js"></script></body></html>

帮忙调试一下!!!主要作用是为文档创建一个“缩略语列表”的函数!大家帮忙看看!

另外请教怎么调试js的代码!



[解决办法]
楼主去下个firefox浏览器,然后下个 firebug插件,就可以慢慢调试了

热点排行
Bad Request.