现在的位置: 首页 > 综合 > 正文

javaScript.DOM. 编程艺术第二版

2014年01月26日 ⁄ 综合 ⁄ 共 1415字 ⁄ 字号 评论关闭
<BODY>
  <h1> what is the Document Object Model?</h1>
	<p>
		The <abbr title="...ConSortium">W3C</abbr> define<abbr title="doment object">
		DOM</abbr> as:
	</p>
	<blockquote cite="http://www.w3c.org/DOM/">
	<p>
		Afds fd  fds 
		and .... of document.
	</p>
	<p>
		It is
		The <abbr title="...YF is">YF</abbr>
	</p>


	 <script type="text/javascript">
	    displayAbbreviations();
		function displayAbbreviations(){
			var abbreviations = document.getElementsByTagName("abbr");
			var abblength=abbreviations.length;
			
			if(abblength>0){
			    var defs = new Array();
				for(var i=0;i<abblength;i++){
					var key = abbreviations[i].lastChild.nodeValue//W3C DOM YF
					var attTitle = abbreviations[i].getAttribute("title");
					 defs[key]=attTitle;
				    }

				var dlist = document.createElement("dl");
				 for(key in defs){
				 //dt
				//	alert(key);
				//	alert(defs[key]);
				  var definition = defs[key];
				  var dtitle = document.createElement("dt");
				  var dtitle_text = document.createTextNode(key);
				  dtitle.appendChild(dtitle_text);
				  dlist.appendChild(dtitle);
				  //dd
				  var ddesc = document.createElement("dd");
				  var ddesc_text = document.createTextNode(definition);
				  ddesc.appendChild(ddesc_text);
				  dlist.appendChild(ddesc);
				 }
				//h2
				var header = document.createElement("h2");
				var header_text=document.createTextNode("Abbreviations");
				    header.appendChild(header_text);
				//body
				    //document.getElementsByTagName("body")[0];
				  //document.body.appendChild(header);
					//document.body.appendChild(dlist);
                 document.getElementsByTagName("body")[0].appendChild(dlist);
				 document.getElementsByTagName("body")[0].appendChild(header);

			      }
	         	}
			


	</script>
 </BODY>
</HTML>

抱歉!评论已关闭.