Home > Web Front-end > JS Tutorial > body text

JavaScript for automatically adding Digg This! button_hacker nature

WBOY
Release: 2016-05-16 19:22:35
Original
922 people have browsed it
复制代码 代码如下:

var main=document.getElementById("main");
var singlepost=false;
var firstpost;
var anchor;
for(var i=0;i{
  if(main.childNodes[i].className&&main.childNodes[i].className=="post")
  {
    var post=main.childNodes[i];
    if(!firstpost)
    {
      firstpost=post;
    }
    for(var j=0;j    {
      if(post.childNodes[j].className&&post.childNodes[j].className=="posthead")
      {
        var posthead=post.childNodes[j];
        if(posthead.childNodes[1]&&posthead.childNodes[1].tagName&&posthead.childNodes[1].tagName=="H2")
        {
          if(posthead.childNodes[1].childNodes[1]&&posthead.childNodes[1].childNodes[1].tagName&&posthead.childNodes[1].childNodes[1].tagName=="A")
          {
            anchor=posthead.childNodes[1].childNodes[1];
          }
          else
          {
            anchor=posthead.childNodes[1].childNodes[0];
          }
        }
        else
        {
          anchor=posthead.childNodes[0].childNodes[0];
        }
        anchor.style.fontSize="14pt";
        if(anchor.className&&anchor.className=="singleposttitle")
        {
          singlepost=true;
        }
      }
    }
  }
}
if(singlepost)
{
  var postfoot=document.createElement("div");
  firstpost.appendChild(postfoot);
  postfoot.className="postfoot";
  postfoot.innerHTML="Add to del.icio.us";
  postfoot.innerHTML ="Digg This!";
  postfoot.innerHTML ="Share on Facebook";
  postfoot.innerHTML ="Google Bookmark This";

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template