"Richard Cornford" <Ri*****@litote s.demon.co.uk> wrote in message
news:ca******** ***********@new s.demon.co.uk.. .
Stephen Chalmers wrote: Richard Cornford wrote: And no support for IE 6 in standards mode.
The OP's site wasn't selecting standards mode, which is difficult to
support for the purposes of setting a div's position. Mozilla
requires a string parameter, including 'px', while Netscape 4 at
least, requires an integer.
The CSS units problem is not at all difficult to handle:-
<URL: http://jibberingg.com/faq/faq_notes/misc.html#mtCSSUn >
OK, but another pitfall is that Mozilla doesn't update
document.docume ntElement.scrol lTop, so it's just as well that
window.pageYOff set is still available as it must be used instead.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 strict//EN">
<HTML>
<HEAD>
<style>
..slider{positi on:absolute;lef t:30px; top:20px; border-style:ridge;
border-color:#0000ff; border-width:4px;
background-color:#000080; color:#ffffff; padding:10px; font-weight:bold}
</style>
</HEAD>
<BODY>
<DIV class=slider ID=slide>
Scroll the page & I will hide until the page stops.
</DIV>
<SCRIPT>
// (C)S Chalmers
function vPosData()
{
this.index=0;
this.v=0;
if( typeof(window.p ageYOffset)!='u ndefined' ) //must test first
this.index=3;
else
if( typeof(document .body.scrollTop )!='undefined' )
this.index=( document.compat Mode &&
document.compat Mode.indexOf("C SS")==0 ) ? 1 : 2;
this.getVPos();
}
vPosData.protot ype.getVPos=fun ction()
{
switch(this.ind ex)
{
case 3: this.v=window.p ageYOffset; break;
case 2: this.v=document .body.scrollTop ; break;
case 1: this.v=document .documentElemen t.scrollTop; break;
case 0: this.v=0;
}
return this.v;
}
var stopWait=null, dr=getDivRef('s lide'), scrollPeriod=nu ll, vp=new
vPosData(), oldVPos=vp.v;
function moveDiv(dRef)
{
if(dRef)
{
dRef.visibility ='hidden';
clearTimeout(st opWait);
stopWait=setTim eout("getDivRef ('slide').visib ility='visible' ",800);
dRef.top=20+vp. getVPos()+(type of(dRef.top)==' string'?'px':0) ;
}
}
function getDivRef(divId )
{
return document.getEle mentById
?
document.getEle mentById(divId) .style
:document.layer s
?
document.layers[divId]
:document.all
?
document.all(di vId).style
:null;
}
scrollPeriod=se tInterval("if(o ldVPos!=vp.getV Pos()){oldVPos= vp.getVPos();mo v
eDiv(dr)}",200) ; //NN4 fix
window.onscroll =function()
{
if(scrollPeriod !=null)
{
clearInterval(s crollPeriod);
scrollPeriod=nu ll;
}
moveDiv(dr);
};
//// Line generator only - REMOVE ////
for(var i=0, repeatCount=100/document.locati on.href.length;
i<repeatCount;i ++)
for(var j=0; j<document.loca tion.href.lengt h;j++)
document.write( document.locati on.href.charAt( j)+"<BR>");
///////////////////////////////////////
</SCRIPT>
</BODY>
</HTML>
--
S.C.