为了账号安全,请及时绑定邮箱和手机立即绑定

按照Javascript DOM书来的,为什么一直在给我说definition重复定义了求大神指点一二呀。

按照Javascript DOM书来的,为什么一直在给我说definition重复定义了求大神指点一二呀。

html:<!doctype html><html><head><meta charset="utf-8" /><title>Explaining the Document Object Model</title><link rel="stylesheet" media="screen" href="typographt.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 Objec Model">DOM</abbr> as:</p><blockquote cite="http://www.w3.org/DOM/"><p>A platform- and language-neutral interface that will allow programs and sceipts to dynamically access and update the content,structure and style of documents.</p></blockquote><p>IT is an <abbr title="Applicarion Programming Interface">API</abbr>that can be used to navigate <abbr title="HyoerText Markup Language">HTML</abbr>and<abbr title="eXtensible Markup">XML</abbr> document.</p>    <script src="addLoadEvent(func).js"></script>    <script src="displayAbbreviations.js"></script></body></html>JS:function displayAbbreviations(){    "use strict";    addLoadEvent(displayAbbreviations);    if(!document.getElementsByTagName || !document.createElement || !document.createTextNode)     {        return false;    }        var abbreviations = document.getElementsByTagName("abbr");    if (abbreviations.length < 1)     {        return false;    }    var defs = new Array();    for (var i=0; i<abbreviations.length;i++){        var current_abbr = abbreviations[i]    ;        var definition = current_abbr.getAttribute("title");        var key = current_abbr.lastChild.nodeValue;        defs[key] = definition;    }    var dlist = document.createElement("dl");    for(key in defs){        var definition = defs[key];        var dtitle = document.createElement("dt");        var dtitle_text = document.createTextNode(key);        dtitle.appendChild(dtitle_text);        var ddesc = document.createElement("dd");        var ddesc_text = document.createTextNode(definition);        ddesc.appendChild(ddesc_text);        dlist.appendChild(dtitle);        dlist.appendChild(ddesc);    }    var header = document.createElement("h2");    var header_text = document.createTextNode("Abbreviations");    header.appendChild(header_text);    document.body.appendChild(header);    document.body.appendChild(dlist);}function addLoadEvent(func){    "use strict";    var oldonload =  window.onload;    if (typeof window.onload !== 'function'){        window.onload = func;    } else {        window.onload = function(){            oldonload();            func();        };    }}
查看完整描述

1 回答

?
qq_秋城纸扇雪纷飞_0

TA贡献1条经验 获得超0个赞

还报错 key 超出使用范围,真心不懂咯

查看完整回答
反对 回复 2018-03-28
  • 1 回答
  • 0 关注
  • 741 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号