MediaWiki:Navigation.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K |
K |
||
Zeile 1: | Zeile 1: | ||
− | var nv = document.getElementById(' | + | var nv = document.getElementById('nav'); |
function findPos(b) { //Position von b ( = nv) ermitteln | function findPos(b) { //Position von b ( = nv) ermitteln |
Version vom 7. Januar 2012, 00:33 Uhr
var nv = document.getElementById('nav');
function findPos(b) { //Position von b ( = nv) ermitteln
var a = 0;
if(b.offsetParent)
for(a = b.offsetTop;b = b.offsetParent;)
a += b.offsetTop;
return[a];
}
var nvY = findPos(nv);
alert(nvY);
function fixNv() {
//Scrollposition ermitteln
var scrY = document.documentElement.scrollTop || // Explorer 6 Strict
document.body.scrollTop || //all other Explorers
self.pageYOffset ||
0;
if(self.pageYOffset)
scrY = self.pageYOffset;
else if(document.documentElement && document.documentElement.scrollTop)
scrY = document.documentElement.scrollTop;
else if(document.body)
scrY = document.body.scrollTop;
if(typeof document.body.style.maxHeight != "undefined" && nv!='') // nur neuere Browser
nv.className = scrY > nvY - 16 ? "fixed" : "absolute";
}
function styleNv() {
var selflink = document.getElementById('chapters').getElementsByTagName('STRONG')[0]||0;
if (selflink && selflink.parentNode.parentNode.parentNode.parentNode.tagName == 'LI') {
selflink.parentNode.parentNode.parentNode.parentNode.className='self_parent';
}
}
styleNv();
window.onscroll = fixNv;