<head>
<meta name="keywords" content="a,b,c,d">
<meta name="keywords" content="a,b,c,d">
</head>
<script>
alert(document.getElementsByTagName("meta").length)
</script>

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <meta name="keywords" content="a,b,c,d">   
    <meta name="description" content="abcdefg efgh a,b">  
    <style type="text/css">
    </style>
    <script type="text/javascript">
    window.onload=function(){
    var oHead=document.documentElement.childNodes[0];
    var oMeta=oHead.getElementsByTagName("meta");
    for(var i=0;i<oMeta.length;i++){
    if(oMeta[i].getAttribute("name")=="keywords"){
    var keyws=oMeta[i].getAttribute("name").split("");
    }
    }
    var sHtml="";
    for(var i=0;i<keyws.length;i++){
    sHtml+="<a href='...keywords='"+keyws[i]+">"+keyws[i]+" </a><br/>";  
    }
    document.body.innerHTML=sHtml;

    </script>
    </head>
    <body></body>
    </html>
      

  2.   

    出来的结果(有链接, 不过每个字母的链接是...keywords=, 不带变量)







    s 结果应该是(链接应该是...keywords=a / b /c /d)
    a
    b
    c
    d另不是onload就调用函数, 而是要在body某处调用, 同时显示出来的应该被搜索引擎能读到(有办法做到这点吗?).
      

  3.   


    <html>  
    <head>  
    <title>....  </title>  
    <meta name="Keywords" content="a,b,c,d">  
    <meta name="description" content="abcdefg efgh a,b">  
    </head>
    <body>
    <div id="pad"></div>
    <script>
    var list = document.getElementsByTagName("META");
    var oDiv = document.getElementById("pad");for(var i=0;i<list.length;i++){
      if(list[i].name.toLowerCase()=="keywords"){
         var s = list[i].content;
         var arr = s.split(",");
         for(j=0;j<arr.length;j++){
            var a = document.createElement("A");
            a.href="xxxx.xxx?keyword=" + arr[j];
            a.innerHTML = arr[j];
            oDiv.appendChild(a);
            oDiv.appendChild(document.createElement("<br>"));
         }
      }
    }
    </script>
    </body>
      

  4.   

    <html>  
    <head>  
    <title>readKeyWords_test</title>  
    <meta name="keyWords" content="a,b,c,d,e,f,g" />
    <meta name="description" content="abcdefg efgh a,b">
    <style type="text/css">
    a{margin:20px;}
    </style>
    <script type="text/javascript">
    function readKeyWords(){
    try{
        var source=document.getElementsByTagName("meta");
        for(var i=0;i<source.length;i++){
            if(source[i].name.toString().toLowerCase()=="keywords"){
                var data=source[i].content.split(",");
                for(var j=0;j<data.length;j++){
                    var link=document.createElement("a");
                    link.setAttribute("href","http://www.***.com/?keyWords="+data[j]);
                    link.innerHTML=data[j];
                    document.body.appendChild(link);
                }
            }
        }
    }catch(e){alert(e.Message);}
    }
    </script>
    </head>  
    <body>
    <a href="javascript:readKeyWords();">readKeyWords</a>
    </body>
      

  5.   

     同时显示出来的应该被搜索引擎能读到(有办法做到这点吗) 这个就不知道了...刚那个弄太快了~~~写错~改成content属性就可以了~
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <meta name="keywords" content="a,b,c,d">   
    <meta name="description" content="abcdefg efgh a,b">  
    <style type="text/css">
    </style>
    <script type="text/javascript">
    function aa(){
    var oMeta=document.getElementsByTagName("meta");
    for(var i=0;i<oMeta.length;i++){
    if(oMeta[i].getAttribute("name")=="keywords"){
    var keyws=oMeta[i].getAttribute("content").split(",");
    }
    }
    var sHtml="";
    for(var i=0;i<keyws.length;i++){
    sHtml+="<a href='...keywords='"+keyws[i]+">"+keyws[i]+" </a><br/>";  
    }
    document.body.innerHTML=sHtml;

    </script>
    </head>
    <body>
    <script>
    aa();
    </script>
    </body>
    </html>
      

  6.   

    !!我怎么和hookee 写的一样啊?我可绝对没抄袭哦~~