JavaScript & PHP‎ > ‎

Auto Cite Link

About

Takes the CITE attribute of <q> and creates a superscript link to the referenced page, and takes the CITE attribute of <blockquote> and creates a normal link at the end of the block.

The superscript link's text is a number that increases for each CITE (i.e. the first <q> with a CITE is "1", the second is "2", etc.). The script does not keep the same number for the same source; if a later CITE has the same URL as an earlier CITE it will not be given the same number as the first CITE.

Example

NOTE: The example is non-functional; once I spend more time with Google Sites I'll hopefully get all the JavaScript working. At the moment my primary goal is availability of the scripts. The example is, however, representative of the appearance of the proper script.

The first inline quote1 will gain a superscript 1, an inline quote without a CITE will have no link, the second inline quote2 will get a superscript 2, and so on.

A <blockquote> with a CITE will gain a link at the end of it that links to the given URL, with the URL also being used for the text of the link. The different methods for outputting the value of the CITE attribute are because <q> is an inline element, and as such the superscript is less disruptive to the flow of the text.

http://www.6times9.com/javascript/citelink/

As with the inline quotes, a <blockquote> without a CITE will not gain a link.

Using

All you need to do put the following at the end of the <head> section:

<script src="citelink.js" type="text/javascript"></script>

Then any <q> and <blockquote> tags with a CITE attribute will automatically gain appropriate links.

For reference, the CITE attribute is optional and must be a URL (that's not because of the script; that's because of how The Powers That Be decided CITE should work). The URL given can be either relative or absolute. For example:

<q cite="/example.html">An inline quote with a relative URL.</q>

<blockquote cite="http://www.example.com/">A block quote with an absolute URL.</blockquote>

Styling

The link inside <q> is just inside a <sup> with no CLASS on either, but the link inside <blockquote> is inside a <p> with the CLASS of "cite".

So the generated code will be:

<q cite="http://www.example.com/">Quoted text<sup><a href="http://www.example.com/">1</a></sup></q>

<blockquote cite="http://www.example.com/"><p>Quoted text</p><p class="cite"><a href="http://www.example.com/">http://www.example.com/</a></p> </blockquote>

For the <blockquote> link, I like font-size: small; text-align: right;, but you can do whatever you prefer.

Feedback

I'd like to hear what you have to say about this or any other project on the site.

If you have any comments, compliments, or suggestions feel free to get in touch and let me know.

Download

Download the latest version using the link below.

Note that the first version uploaded here was last updated 2008-02-09. The date of any subsequent changes will be accurately reflected in the date shown in the table.

SelectionFile type iconFile nameDescriptionSizeRevisionTimeUser
ċ

Download
A script that takes the CITE attribute of <q> and creates a superscript link to the referenced page, and takes the CITE attribute of <blockquote> and creates a normal link at the end of the block.  1k v. 4 23 Mar 2013, 21:42 Richard Winskill
ċ

Download
The script for use with the Firefox add-on "Greasemonkey".   2k v. 4 23 Mar 2013, 21:42 Richard Winskill
Comments