X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fsquelettes%2Fjavascript%2Fsmoothscroll.js;fp=www%2Fsquelettes%2Fjavascript%2Fsmoothscroll.js;h=9b8d4a095a45073c24655dc6b244ca30f8ce3777;hp=0000000000000000000000000000000000000000;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c diff --git a/www/squelettes/javascript/smoothscroll.js b/www/squelettes/javascript/smoothscroll.js new file mode 100644 index 0000000..9b8d4a0 --- /dev/null +++ b/www/squelettes/javascript/smoothscroll.js @@ -0,0 +1,145 @@ +// JavaScript Document +/* Smooth scrolling + Changes links that link to other parts of this page to scroll + smoothly to those links rather than jump to them directly, which + can be a little disorienting. + + sil, http://www.kryogenix.org/ + + v1.0 2003-11-11 + v1.1 2005-06-16 wrap it up in an object +*/ + +var ss = { + fixAllLinks: function() { + // Get a list of all links in the page + var allLinks = document.getElementsByTagName('a'); + // Walk through the list + for (var i=0;i tag corresponding to this href + // First strip off the hash (first character) + anchor = target.hash.substr(1); + // Now loop all A tags until we find one with that name + var allLinks = document.getElementsByTagName('a'); + var destinationLink = null; + for (var i=0;i