显示引文功能手册

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了显示引文功能手册相关的知识,希望对你有一定的参考价值。

JS function that add a link included in the cite attribute of the blackquote html element as sup element close to the blackquote. Takes no argument.

From book Dom Scripting by Jeremy Keith.
  1. function displayCitations() {
  2. var quotes = document.getElementsByTagName("blockquote");
  3. for (var i=0; i<quotes.length; i++) {
  4. if (!quotes[i].getAttribute("cite")) continue;
  5. var url = quotes[i].getAttribute("cite");
  6. var quoteChildren = quotes[i].getElementsByTagName("*");
  7. var quoteChildren = quotes[i].getElementsByTagName('*');
  8. if (quoteChildren.length < 1) continue;
  9. var elem = quoteChildren[quoteChildren.length - 1];
  10. var link = document.createElement("a");
  11. var link_text = document.createTextNode("source");
  12. link.appendChild(link_text);
  13. link.setAttribute("href",url);
  14. var superscript = document.createElement("sup");
  15. superscript.appendChild(link);
  16. elem.appendChild(superscript);
  17. }
  18. }

以上是关于显示引文功能手册的主要内容,如果未能解决你的问题,请参考以下文章