The following body parts:
<! Doctype html> The following is the JS section:
Function addloadevent (func) { //does not matter how many functions are executed after the page is loaded var oldonload = window.onload;if (typeof window.onload != ' function ') {Window.onload = func;} Else{window.onload = function () {oldonload (); func ();}}} Function displayabbreviations () {//Check compatibility if (!document.getelementsbytagname| |! Document.createelement| |! document.createTextNode) return false;var abbreviations = document.getElementsByTagName ("abbr"); //get all acronyms if (abbreviations.length < 1) return false;var defs = new array (); for (var i=0; i < abbreviations.length; i++) { //Traverse these acronyms 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"); //Create definition list for ( key in defs) { //Traversal definition var definition = defs[key]; var Dtitle = document.createelement ("DT"); //Create a definition title var dtitle_text = document.createTextNode (Key);d title.appendchild (dtitle_text); var ddesc = document.createelement ("DD"); //Create definition Description Var ddesc_text = document.createtextnode (definition); Ddesc.appendchild (Ddesc_text); // Add them to the definition list dlist.appendchild (dtitle);d list.appendchild (DDESC);} Var header = document.createelement ("H2"); //Create title var header_text = document.createTextNode ("abbreviations"), Header.appendchild (Header_text);d ocument.body.appendChild (header); //Add the title to the page body Document.body.appendChild (dlist); //Add the definition list to the principal}addloadevent ( Displayabbreviations);
Page Preview Effect:
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/81/FF/wKiom1dGzeexHkaEAAB04bQ87MA881.jpg-wh_500x0-wm_3 -wmp_4-s_1783589737.jpg "title=" 36020160526181952718.jpg "alt=" Wkiom1dgzeexhkaeaab04bq87ma881.jpg-wh_50 "/>
Show thumbnail list JS DOM