JS DOM: Show Source Link table

Source: Internet
Author: User

<! Doctype html>
Function addloadevent (func) {    //does not matter how many functions are executed after the page is loaded  var oldonload  = window.onload;if (typeof window.onload !=  ' function ') {window.onload =  func;} Else{window.onload = function () {oldonload (); func ();}}} Function displaycitations () {//Check compatibility if (!document.getelementsbytagname| |! Document.createelement| |! 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");              //gets the value of the cite property: that is, the link var quotechildern =  quotes[i].getelementsbytagname ("*");       //because there is a line break between the P node and the BLOCKQUOTE node, Many browsers will interpret it as several text nodes, so that the LastChild attribute of the BLOCKQUOTE element node//Check whether the length is less than 1&nbsp, and if so, exit this loop immediately.               //is a text node that is not a P element node. The statement is to get the position of the last element node. Recommendation: If not absolutely sure, be sure to check if (quotechildern.length < 1)  continue;                          //lastchild the NodeType property to avoid getting node errors. var elem = quotechildern[quotechildern.length - 1];            var link = document.createelement ("a");     //Create a element Var link_text = document.createtextnode ("source"); Link.appendchild (Link_text); Link.setattribute ("href",  url);           // Add the href attribute to the new link//Insert link var superscript = document.createelement ("Sup");            //sup element: Specifies that the included text is displayed in the form above, usually slightly smaller than the current font. Superscript.appendchild (link);                              //above statement HTML text: <sup><a href= " http://www.w3.org/DOM/">source</a></sup>elem.appendchild (superscript);         //is appended to the last child node of the variable Elem} }addloadevent (displaycitations);


Browser effects:

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/81/FF/wKioL1dG893xNu75AAAzYOZYmW4003.png-wh_500x0-wm_3 -wmp_4-s_4134423147.png "title=" Qq20160526205722.png "alt=" Wkiol1dg893xnu75aaazyozymw4003.png-wh_50 "/>

JS DOM: Show Source Link table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.