• displayAbbreviations函数与displayCitations函数与displayAccesskeys函数


    if (!document.getElementsByTagName) return false;
    if(!document.createElement) return false;
    if(!document.createTextNode) return false;
    function displayAbbreviations(){
        var abbreviations=document.getElementsByTagName("abbr");
        if (abbreviations.length<1)return false;
        var defs =new Array();
        for (var i = 0; i < abbreviations.length; i++) {
        var current_abbr=abbreviations[i];
        if (current_abbr.childNodes.length<1) continue;
        var definition=current_abbr.getAttribute("title");
        var key=current_abbr.lastChild.nodeValue;
        defs[key]=definition;
        }
    
    var dlist=document.createElement("dl");
    for (key in defs){
        var definition=defs[key];
        var dtitle=document.createElement("dt");
        var dtitle_text=document.createTextNode(key);
        dtitle.appendChild(dtitle_text);
        var ddesc=document.createElement("dd");
        var ddesc_text=document.createTextNode(definition);
        ddesc.appendChild(ddesc_text);
        dlist.appendChild(dtitle);
        dlist.appendChild(ddesc);
    }
    if (dlist.childNodes.length<1) return false;
        var header=document.createElement("h2");
        var header_text=document.createTextNode("Abbreviations");
        header.appendChild(header_text);
        document.body.appendChild(header);
        document.body.appendChild(dlist);
    }
    addLoadEvent(displayAbbreviations);

    此函数用于显示文档中缩略语的信息

    function displayCitations(){
        if (!document.getElementsByTagName) return false;
        if (!document.createElement) return false;
        if (!document.createTextNode) return false;
        var quotes=document.getElementsByTagName("blockquote");
        for (var i = 0; i < quotes.length; i++) {
           if (!quotes[i].getAttribute("cite")) continue;
           var url=quotes[i].getAttribute("cite");
           var quoteChildren=quotes[i].getElementsByTagName('*');
           if (quoteChildren.length<1) continue;
           var elem=quoteChildren[quoteChildren.length-1];
           var link=document.createElement("a");
           var link_text=document.createTextNode("网站详情请点击这里");
           link.appendChild(link_text);
           link.setAttribute("href",url);
           var superscript=document.createElement("sup");
           superscript.appendChild(link);
           elem.appendChild(superscript);
        }
    }
    addLoadEvent(displayCitations);

    此函数用于显示标签网址的链接

    function displayAccesskeys(){
       if (!document.getElementsByTagName) return false;
       if (!document.createElement) return false;
       if (!document.createTextNode) return false;
    
      var links=document.getElementsByTagName("a");
      var akeys=new Array();
      for (var i = 0; i < links.length; i++) {
          var current_link= links[i];
          if (!current_link.getAttribute("accesskey")) continue;
          var key=current_link.getAttribute("accesskey");
          var text=current_link.lastChild.nodeValue;
          akeys[key]=text;
      }
        var list=document.createElement("ul");
        for (key in akeys){
            var text=akeys[key];
            var str=key + ": "+text;
            var item=document.createElement("li");
            var item_text=document.createTextNode(str);
            item.appendChild(item_text);
            list.appendChild(item);
        }
        var header=document.createElement("h3");
        var header_text=document.createTextNode("Accesskeys");
        header.appendChild(header_text);
        document.body.appendChild(header);
        document.body.appendChild(list);
    }
    addLoadEvent(displayAccesskeys);

    此函数用于把链接的快速菜单显示在文档中

  • 相关阅读:
    玩转java多线程(wait和notifyAll的正确使用姿势)
    shell脚本编写之Hello World
    面试题录:数据库篇
    面试题录:笔试题篇
    浅谈String、StringBuffer与StringBuilder
    Java攻城狮面试题录:笔试篇(1)
    Android程序中,内嵌ELF可执行文件-- Android开发C语言混合编程总结
    TensorFlow从1到2(十五)(完结)在浏览器做机器学习
    TensorFlow从1到2(十四)评估器的使用和泰坦尼克号乘客分析
    TensorFlow从1到2(十二)生成对抗网络GAN和图片自动生成
  • 原文地址:https://www.cnblogs.com/CClarence/p/4910653.html
Copyright © 2020-2023  润新知