MediaWiki:Navigation.js: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
K
K
Zeile 1: Zeile 1:
 +
 
var nv = document.getElementById('siteNotice');  
 
var nv = document.getElementById('siteNotice');  
  
Zeile 8: Zeile 9:
 
   return[a];
 
   return[a];
 
}
 
}
 +
var nvY = findPos(nv);
 +
//alert(nvY);
  
 
function fixNv() {
 
function fixNv() {
Zeile 22: Zeile 25:
 
     scrY = document.body.scrollTop;
 
     scrY = document.body.scrollTop;
 
   if(typeof document.body.style.maxHeight != "undefined" && nv!='') // nur neuere Browser
 
   if(typeof document.body.style.maxHeight != "undefined" && nv!='') // nur neuere Browser
     nv.parentNode.className = scrY > nvY - 16 ? "fixed" : "absolute";
+
     nv.className = scrY > nvY - 16 ? "fixed" : "absolute";
 
}
 
}
  
Zeile 30: Zeile 33:
 
     selflink.parentNode.parentNode.parentNode.parentNode.className='self_parent';
 
     selflink.parentNode.parentNode.parentNode.parentNode.className='self_parent';
 
   }   
 
   }   
}
+
}  
 +
styleNv();
 
window.onscroll = fixNv;
 
window.onscroll = fixNv;

Version vom 4. Januar 2012, 16:19 Uhr

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

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;