»
AnglaisFranaisVietnamien

Imprimer - Simple JavaScript Blockquotes - JavaScriptBank.com

Version complte: jsB@nk » Utilitaire » Simple JavaScript Blockquotes
URL: http://www.javascriptbank.com/simple-javascript-blockquotes.html

Simple JavaScript Blockquotes © JavaScriptBank.comUtilisez cette JavaScript d'ajouter le bon titre et la citation à votre prix. Facile à utiliser!

Version complte: jsB@nk » Utilitaire » Simple JavaScript Blockquotes
URL: http://www.javascriptbank.com/simple-javascript-blockquotes.html



CSS
<style type="text/css">/*Created by: Dunstan Orchard Web Site: http://1976design.com/ Posted: November 29, 2006 */blockquote { font-style: normal; margin: 20px 40px;}blockquote div.source { color: #555; margin-top: -1em; text-align: right;}</style>


JavaScript
<script language="javascript" name="simpleBlockquotes.js">// Altered from original idea by Simon Willison at:// http://simon.incutio.com/archive/2002/12/20/blockquoteCitationsfunction extractBlockquoteInfo() { quotes = document.getElementsByTagName('blockquote'); for (i = 0; i < quotes.length; i++) {  cite = quotes[i].getAttribute('cite');  title = quotes[i].getAttribute('title');  alert(title );  if ((cite) && (cite != '')) {   if ( (cite.match('http://', 'i')) || (cite.match('ftp://', 'i')) || (cite.match('person://', 'i')) ) {    newlink = document.createElement('a');    newlink.setAttribute('href', cite);    newlink.setAttribute('title', ('Go to ' + cite));    title = quotes[i].getAttribute('title');    if ((title) && (title != '')) {     newlink.appendChild(document.createTextNode(title));   } else {   newlink.appendChild(document.createTextNode('Quote source'));   }    newdiv = document.createElement('div');    newdiv.className = 'source';    newdiv.appendChild(document.createTextNode('u2014 '));    newdiv.appendChild(newlink);    quotes[i].appendChild(newdiv);  } else {    newdiv = document.createElement('div');    newdiv.className = 'source';    newdiv.appendChild(document.createTextNode('u2014 ' + cite));    quotes[i].appendChild(newdiv);  } } else if ((title) && (title != '')) {   newdiv = document.createElement('div');   newdiv.className = 'source';   newdiv.appendChild(document.createTextNode('u2014 ' + title));   quotes[i].appendChild(newdiv); } }}/* window.onload = function(e) {extractBlockquoteInfo();} */function addLoadEvent(func) {  var oldonload = window.onload;  if (typeof window.onload != 'function') {    window.onload = func;  } else {    window.onload = function() {      if (oldonload) {        oldonload();      }      func();    }  }}addLoadEvent(function(e) {  extractBlockquoteInfo();});</script>


HTML
<blockquote cite="http://fmg-www.cs.ucla.edu/fmg-members/popek/" title="Gerald Popek"><p>Science is supposedly the method by which we stand on the shoulders of those who came before us. In computer science, we all are standing on each others' feet.</p></blockquote>