Changeset 33 for collected/trunk
- Timestamp:
- 12/14/07 13:58:02 (13 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
collected/trunk/html-test-cases/getting-tabindex.html
r30 r33 7 7 <title>Getting the tabindex value of an element with JavaScript</title> 8 8 <script type="text/javascript"> 9 function Logger( id){10 this._ id = id;9 function Logger(){ 10 this._rows = ""; 11 11 } 12 Logger.prototype. _makeTd = function(text){13 va r td = document.createElement("td");14 t d.appendChild(document.createTextNode(text));15 return td;12 Logger.prototype.log = function(desc, mechanism, value){ 13 value = (value === null) ? "null" : value; 14 this._rows += "<tr><td>" + desc + "<\/td><td>" 15 + mechanism + "<\/td><td>" + value + "<\/td><\/tr>\n"; 16 16 }; 17 Logger.prototype.log = function(desc, mechanism, value){ 18 var table = document.getElementById(this._id); 19 var tbody = table.getElementsByTagName("tbody")[0]; 20 var tr = document.createElement("tr"); 21 tr.appendChild(this._makeTd(desc)); 22 tr.appendChild(this._makeTd(mechanism)); 23 if(value === null){ 24 tr.appendChild(this._makeTd("null")); 25 }else{ 26 tr.appendChild(this._makeTd(value)); 27 } 28 tbody.appendChild(tr); 17 Logger.prototype.getHTML = function(){ 18 return "<table><thead>" 19 + "<tr><th>Element<\/th><th>Mechanism<\/th><th>Value<\/th><\/tr>" 20 + "<\/thead><tbody>\n" 21 + this._rows 22 + "<\/tbody><\/table>\n"; 29 23 }; 30 24 Logger.prototype.logGetAttribute = function(id, desc, attr, iFlags){ … … 76 70 return navigator.userAgent.indexOf("MSIE") != -1; 77 71 } 72 function showTableSource(){ 73 document.getElementById("source").style.display = "block"; 74 } 78 75 function removeTabindex(id){ 79 76 var elem = document.getElementById(id); … … 89 86 removeTabindex("div-tabindex-removed"); 90 87 removeTabindex("input-tabindex-removed"); 91 logger = new Logger( "log");88 logger = new Logger(); 92 89 logger.logTabindex("div-no-tabindex", "div with no tabindex"); 93 90 logger.logTabindex("div-tabindex-1", 'div with tabindex="1"'); … … 96 93 logger.logTabindex("input-tabindex-1", 'input with tabindex="1"'); 97 94 logger.logTabindex("input-tabindex-removed", "input with tabindex removed"); 95 document.getElementById("log").innerHTML = logger.getHTML(); 96 var sourceTextNode = document.createTextNode(logger.getHTML()); 97 document.getElementById("source").appendChild(sourceTextNode); 98 98 } 99 99 </script> … … 104 104 <div id="userAgent"></div> 105 105 <h2>Results</h2> 106 <table id="log"> 107 <thead> 108 <tr><th>Element</th><th>Mechanism</th><th>Value</th></tr> 109 </thead> 110 <tbody></tbody> 111 </table> 106 <div id="log"></div> 107 <hr> 108 <div><button onclick="showTableSource()">Show table source</button></div> 109 <pre id="source" style="display:none"></pre> 112 110 <hr> 113 111 <div id="div-no-tabindex"></div> 114 112 <div id="div-tabindex-1" tabindex="1"></div> 115 113 <div id="div-tabindex-removed" tabindex="1"></div> 114 <div> 116 115 <input id="input-no-tabindex"> 117 116 <input id="input-tabindex-1" tabindex="1"> 118 117 <input id="input-tabindex-removed" tabindex="1"> 118 </div> 119 119 </body> 120 120
