⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 displayaccesskeys.js

📁 《JavaScript DOM编程艺术》一书中的配套源代码
💻 JS
字号:
function displayAccesskeys() {  if (!document.getElementsByTagName || !document.createElement || !document.createTextNode) return false;// get all the links in the document  var links = document.getElementsByTagName("a");// create an array to store the accesskeys  var akeys = new Array();// loop through the links  for (var i=0; i<links.length; i++) {    var current_link = links[i];// if there is no accesskey attribute, continue the loop    if (current_link.getAttribute("accesskey") == null) continue;// get the value of the accesskey    var key = current_link.getAttribute("accesskey");// get the value of the link text    var text = current_link.lastChild.nodeValue;// add them to the array    akeys[key] = text;  }// create the list  var list = document.createElement("ul");// loop through the accesskeys  for (key in akeys) {    var text = akeys[key];//  create the string to put in the list item    var str = key + " : "+text;// create the list item    var item = document.createElement("li");    var item_text = document.createTextNode(str);    item.appendChild(item_text);// add the list item to the list    list.appendChild(item);  }// create a headline  var header = document.createElement("h3");  var header_text = document.createTextNode("Accesskeys");  header.appendChild(header_text);// add the headline to the body  document.body.appendChild(header);// add the list to the body  document.body.appendChild(list);}addLoadEvent(displayAccesskeys);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -