/* $Id: anchor_fix.js,v 1.2 2008/11/26 09:34:47 max Exp $ vim: set ts=2 sw=2 sts=2 et: */ /* Fix a.href if base url is defined for page */ function anchor_fix() { var links = document.getElementsByTagName('A'); var m; for (var i = 0; i < links.length; i++) { if (links[i].href && (m = links[i].href.match(/^#([\w\d_]+)$/))) { links[i].href = 'javascript:void(self.location.hash = "' + m[1] + '");'; } } } if (window.addEventListener) window.addEventListener("load", anchor_fix, false); else if (window.attachEvent) window.attachEvent("onload", anchor_fix);