MediaWiki:Navigation.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K |
K |
||
Zeile 1: | Zeile 1: | ||
− | var | + | var nav = document.getElementById('nv'); |
− | function findPos(b) { //Position von b ( = | + | function findPos(b) { //Position von b ( = nav) ermitteln |
var a = 0; | var a = 0; | ||
if(b.offsetParent) | if(b.offsetParent) | ||
Zeile 9: | Zeile 9: | ||
return[a]; | return[a]; | ||
} | } | ||
− | var nvY = findPos( | + | var nvY = findPos(nav); |
alert(nvY); | alert(nvY); | ||
Zeile 24: | Zeile 24: | ||
else if(document.body) | else if(document.body) | ||
scrY = document.body.scrollTop; | scrY = document.body.scrollTop; | ||
− | if(typeof document.body.style.maxHeight != "undefined" && | + | if(typeof document.body.style.maxHeight != "undefined" && nav!='') // nur neuere Browser |
− | + | nav.className = scrY > nvY - 16 ? "fixed" : "absolute"; | |
} | } | ||
Version vom 7. Januar 2012, 00:35 Uhr
var nav = document.getElementById('nv');
function findPos(b) { //Position von b ( = nav) ermitteln
var a = 0;
if(b.offsetParent)
for(a = b.offsetTop;b = b.offsetParent;)
a += b.offsetTop;
return[a];
}
var nvY = findPos(nav);
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" && nav!='') // nur neuere Browser
nav.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;