Ceiling BAR + large image loading and scrolling

Source: Internet
Author: User

<! Doctype HTML>
<HTML>
<Head>
<Meta charset = "UTF-8">
<Title> untitled document </title>
<Style>
* {Margin: 0; padding: 0 ;}
. Box {position: relative; padding: 50px; border-bottom: 1px solid red ;}
. Box IMG {display: block; width: pixel PX; Height: 800px ;}
</Style>
<SCRIPT>
Window. onload = function ()
{
VaR aimg = Document. getelementsbytagname ('img ');


//
// The first screen
VaR winhsf-document.doc umentelement. clientheight;
For (VAR I = 0; I <aimg. length; I ++)
{
Aimg [I]. _ Top = getpos (aimg [I]). Top;
If (aimg [I]. _ top <winh)
{

Aimg [I]. src = aimg [I]. getattribute ('_ src ');
Aimg [I]. B = true; // switched
};
};
VaR obox1 = Document. getelementbyid ('box1 ');
VaR obox2 = Document. getelementbyid ('box2 ');
VaR Top = getpos (obox1). Top;

Window. onscroll = function ()
{Var scrolltop = Document. Body. scrolltop | document.doc umentelement. scrolltop;
VaR winhsf-document.doc umentelement. clientheight;
{For (VAR I = 0; I <aimg. length; I ++)
{

If (aimg [I]. B) continue;

If (aimg [I]. _ top <= winh + scrolltop)
{

// Aimg [I]. src = aimg [I]. getattribute ('_ src ');

(
Function (INDEX ){
VaR oimg = new image ();
Oimg. onload = function ()
{
Aimg [Index]. src = This. SRC;
};
Oimg. src = aimg [I]. getattribute ('_ src ');
}) (I );

Aimg [I]. B = true;
};
If (scrolltop> = top)
{
Obox1.style. Position = 'fixed ';
Obox1.style. Left = 0;
Obox1.style. Top = 0;
Obox2.style. Display = "Block ";
}
Else
{
Obox1.style. Position = "";
Obox2.style. Display = "NONE ";
};

 

};
};
};
};

 

Function getpos (OBJ)
{
VaR L = 0;
VaR T = 0;
While (OBJ)
{
L + = obj. offsetleft;
T + = obj. offsettop;
OBJ = obj. offsetparent;
};

Return {left: l, top: t };
};

</SCRIPT>
</Head>

<Body>
<Div class = "box">

</Div>

<Div class = "box">

</Div>

<Div class = "box">
<P> </P>
</Div>

<Div id = "box1" style = "display: block; Right: 0; width: 100%; padding: 10px; text-align: center; font-weight: bold; Background: # CCC; Z-index: 5555; ">
The body and soul are always on the road... </Div>
<Div style = "height: 120px; display: none;" id = "box2"> </div>
</Div>

<Div class = "box">

</Div>

<Div class = "box">

</Div>

<Div class = "box">

</Div>

<Div class = "box">

</Div>

<Div class = "box">

</Div>
</Body>
</Html>

Ceiling BAR + large image loading and scrolling

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.