<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head >
< Title > JS + CSS floating layer with screen scrolling </ Title >
< Style >
HTML, body {
Height : 2000px ;
}
</ Style >
</ Head >
< Body >
< Div ID = "AA" Style = "Width: 200px; Height: 200px; Background: # c0c0c0 ;" >
< Div Align = "Right" > < A Href = "Javascript: viod (0 )" Onclick = "Divclose ()" > Close</ A > </ Div >
</Div>
</ Body >
</ Html >
< Script >
Function Scroll (p ){
VaR D = Document, W = Window, O = D. getelementbyid (P. ID), IE6 = / MSIE 6 / I. Test (navigator. useragent );
If (O ){
O.style.css text + = " ; Position: " + (P. f &&! IE6 ? ' Fixed ' : ' Absolute ' ) + " ; " + (P. R ? ' Left ' : " Right " ) + " : 0; " + (P. t ! = Undefined ? ' Top: ' + P.t + ' Px ' : ' Bottom: 0 ' );
If ( ! P. f | IE6 ){
- Function (){
VaR T = 500 , St = D.doc umentelement. scrolltop | D. Body. scrolltop, C;
C = St - O. offsettop + (P. t ! = Undefined ? P. t :( W. innerheight | D.doc umentelement. clientheight) - O. offsetheight );
C ! = 0 && (O. style. Top = O. offsettop + Math. Ceil (math. Abs (c) / 10) * (C <0? -) + 'Px ', t = 10 );
SetTimeout (arguments. callee, T)
}()
}
}
}
Scroll ({
ID: ' AA '
})
Function Divclose ()
{
Document. getelementbyid ( " AA " ). Style. Display = ' None ' ;
}
</ Script >