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

📄 displaycitations.js

📁 《JavaScript DOM编程艺术》一书中的配套源代码
💻 JS
字号:
function displayCitations() {  if (!document.getElementsByTagName || !document.createElement || !document.createTextNode) return false;// get all the blockquotes  var quotes = document.getElementsByTagName("blockquote");// loop through all the blockquotes  for (var i=0; i<quotes.length; i++) {// if there is no cite attribute, continue the loop    if (!quotes[i].hasAttribute("cite")) continue;// store the cite attribute    var url = quotes[i].getAttribute("cite");// get all the element nodes in the blockquote    var quoteChildren = quotes[i].getElementsByTagName('*');// if there are no element node, continue the loop    if (quoteChildren.length < 1) continue;// get the last element node in the blockquote    var elem = quoteChildren[quoteChildren.length - 1];// create the markup    var link = document.createElement("a");    var link_text = document.createTextNode("source");    link.appendChild(link_text);    link.setAttribute("href",url);    var superscript = document.createElement("sup");    superscript.appendChild(link);// add the markup to the last element node in the blockquote    elem.appendChild(superscript);  }}addLoadEvent(displayCitations);

⌨️ 快捷键说明

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