MediaWiki:Navigation.js: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
K
K
Zeile 2: Zeile 2:
 
var nav = document.getElementById('nv');  
 
var nav = document.getElementById('nv');  
  
 +
alert('ok');
 
function findPos(b) {  //Position von b ( = nav) ermitteln
 
function findPos(b) {  //Position von b ( = nav) ermitteln
 
   var a = 0;
 
   var a = 0;
Zeile 10: Zeile 11:
 
}
 
}
 
var nvY = findPos(nav);
 
var nvY = findPos(nav);
alert(nvY);
 
  
 
function fixNv() {
 
function fixNv() {

Version vom 7. Januar 2012, 00:38 Uhr

var nav = document.getElementById('nv'); 

alert('ok');
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);

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;