Slide JS Code

Source: Internet
Author: User

<! 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> magic Atlas </title>
<Style type = "text/CSS">
Body {margin: 0; padding: 0; Background: #000; color: # CCC; width: 100%; Height: 100%; overflow: hidden; cursor: hand}
# Cover {width: 100%; overflow: hidden; position: relative ;}
# Cover IMG {position: absolute; left: 0; top: 0; opacity: 0.1}
# Leftbtn {position: absolute; left: 0; top: 40%;
Background: URL ("/jscss/demoimg/201101/prev.png") No-repeat scroll Left top transparent;
Display: block;
Height: 51px;
Line-Height: 51px;
Overflow: hidden;
Text-indent:-99px;
Width: 55px; cursor: pointer ;}
# Rightbtn {
Position: absolute; Right: 0; top: 40%;
Background: URL ("/jscss/demoimg/201101/next.png") No-repeat scroll Left top transparent;
Display: block;
Height: 51px;
Line-Height: 51px;
Overflow: hidden;
Text-indent:-99px;
Width: 55px; cursor: pointer ;}
# Thumb {position: absolute; left: 0; bottom: 0; Height: 100px; display: None}
# Thumb Li {float: Left ;}
# Num {position: absolute; left: 5px; bottom: 10px; font-size: 24px; font-family: Arial; font-weight: bold ;}
# Loading {
Position: absolute;
Background-image: URL ("/jscss/demoimg/201101/loader.gif ");
Background-position: center;
Background-repeat: No-Repeat;
Width: 100%;
Height: 100px;
Top: 40%;
Display: none;
}
</Style>
<Script language = "JavaScript" type = "text/JavaScript">
If (navigator. Platform = "Win32" & navigator. appname = "Microsoft Internet Explorer" & window. attachevent ){
Window. attachevent ("onLoad", enablealphaimages );
}
Function enablealphaimages (){
VaR rslt = navigator. appversion. Match (/MSIE (\ D + \. \ D + )/,'');
VaR itsallgood = (rslt! = NULL & number (rslt [1]) >=5.5 );
If (itsallgood ){
For (VAR I = 0; I <document. All. length; I ++ ){
VaR OBJ = Document. All [I];
VaR BG = obj. currentstyle. backgroundimage;
VaR IMG = Document. Images [I];
If (BG & BG. Match (/\. PNG/I )! = NULL ){
VaR IMG = BG. substring (5, BG. Length-2 );
VaR offset = obj. Style ["background-position"];
OBJ. style. Filter =
"Progid: DXImageTransform. Microsoft. alphaimageloader (src = '" + IMG + "', sizingmethod = 'crop ')";
OBJ. style. backgroundimage = "URL ('HTTP: // image.dili360.com/photo/0907/touming.gif')"; // replace a transparent PNG Image
OBJ. Style ["background-position"] = offset; // reapply
} Else if (IMG & IMG. SRC. Match (/\. PNG $/I )! = NULL ){
VaR src = IMG. SRC;
IMG. style. width = IMG. Width + "PX ";
IMG. style. Height = IMG. height + "PX ";
IMG. style. Filter =
"Progid: DXImageTransform. Microsoft. alphaimageloader (src = '" + SRC + "', sizingmethod = 'crop ')"
IMG. src = "http://image.dili360.com/photo/0907/touming.gif"; // Replace the transparent PNG Image
}
}
}
}
(Function (){
VaR isready = false; // checks whether the ondomready method has been executed.
VaR readylist = []; // Save the method to be executed in this array
VaR timer; // timer handle
Ready = function (FN ){
If (isready)
FN. Call (document );
Else
Readylist. Push (function () {return fn. Call (this );});
Return this;
}
VaR ondomready = function (){
For (VAR I = 0; I <readylist. length; I ++ ){
Readylist [I]. Apply (document );
}
Readylist = NULL;
}
VaR bindready = function (EVT ){
If (isready) return;
Isready = true;
Ondomready. Call (window );
If (document. removeeventlistener ){
Document. removeeventlistener ("domcontentloaded", bindready, false );
} Else if (document. attachevent ){
Document. detachevent ("onreadystatechange", bindready );
If (window = Window. Top ){
Clearinterval (timer );
Timer = NULL;
}
}
};
If (document. addeventlistener ){
Document. addeventlistener ("domcontentloaded", bindready, false );
} Else if (document. attachevent ){
Document. attachevent ("onreadystatechange", function (){
If (/loaded | complete/). Test (document. readystate ))
Bindready ();
});
If (window = Window. Top ){
Timer = setinterval (function (){
Try {
Isready | document.doc umentelement. doscroll ('left'); // you can run doscroll in IE to determine whether the Dom has been loaded.
} Catch (e ){
Return;
}
Bindready ();
}, 5 );
}
}
})();
</SCRIPT>
</Head>
<Body>
<Div id = "loading"> </div>
<Div id = "cover">
</Div>
<Div id = "leftbtn"> previous </div>
<Div id = "rightbtn"> next </div>
<Div id = "num"> <span id = "curnum"> 1 </span>/<span id = "allnum"> 20 </span> </div>
<SCRIPT type = "text/JavaScript">
VaR $ = function (OBJ ){
Return document. getelementbyid (OBJ)
}
VaR implements wheight?document.doc umentelement. clientheight;
$ ("Cover"). style. Height = running wheight + "PX ";
// Read the small image address and load it into the big image
VaR imgarray = new array ()
Imgarray [0] = "/jscss/demoimg/201101/001 .jpg"
Imgarray [1] = "/jscss/demoimg/201101/002 .jpg"
VaR num = 0;
$ ("Allnum"). innerhtml = imgarray. length;
// Set transparency
VaR _ opacity = 0;
Function fadein (OBJ ){
_ Opacity + = 15;
If (document. All ){
OBJ. style. Filter = "alpha (opacity =" + _ opacity + ")";
}
Else {
OBJ. style. Opacity = _ opacity/100;
}
VaR set = setTimeout (function () {fadein (OBJ)}, 55)
If (_ opacity> = 100) {cleartimeout (SET); _ opacity = 0 ;}
}
Function imgready (event, nextimgobj ){
$ ("Loading"). style. Display = "NONE ";
$ ("Cover"). innerhtml = "";
$ ("Cover"). appendchild (nextimgobj );
VaR event = event | window. event;
Nextimgobj. style. left =-event. clientx * (nextimgobj. width-$ ("cover "). offsetwidth)/$ ("cover "). offsetwidth) + "PX ";
Nextimgobj. style. top =-event. clienty * (nextimgobj. height-$ ("cover "). offsetheight)/$ ("cover "). offsetheight) + "PX ";
$ ("Cover"). onmousemove = function (event ){
VaR event = event | window. event;
Nextimgobj. style. Left =-event. clientx * (nextimgobj. width-this.offsetWidth)/This. offsetwidth) + "PX ";
Nextimgobj. style. Top =-event. clienty * (nextimgobj. height-this.offsetHeight)/This. offsetheight) + "PX ";
}
}

// Next
$ ("Rightbtn"). onclick = function (event ){
Num ++;
If (Num> = imgarray. Length ){
Num = 0
}
VaR nextimgobj = new image ();
Nextimgobj. src = imgarray [num];
VaR nextimgobj2 = new image ();
Nextimgobj2.src = imgarray [num + 1];
// Obtain the index of the current image as the subscript of the array
For (I = 0; I <= imgarray. length; I ++)
{
If (imgarray [I] = imgarray [num])
{
$ ("Curnum"). innerhtml = I + 1;
}
}
$ ("Cover"). innerhtml = "";
$ ("Loading"). style. Display = "Block ";
VaR appname = navigator. appname. tolowercase ();
If (appname. indexof ("Netscape") =-1)
{
If (nextimgobj. readystate = "complete ")
{
Imgready (event, nextimgobj );
Fadein (nextimgobj)
}
Nextimgobj. onreadystatechange = function (){
If (nextimgobj. readystate = "complete ")
{
Imgready (event, nextimgobj );
Fadein (nextimgobj)
}
};
}
Else {
// FF
Nextimgobj. onload = function (){
If (this. Complete = true ){
Imgready (event, nextimgobj );
Fadein (nextimgobj );
}

}
}
}
// Upload
$ ("Leftbtn"). onclick = function (event ){
// Obtain the index of the current image as the subscript of the array
Num --;
If (Num <0 ){
Num = imgarray. Length-1;
}
For (I = 0; I {
If (imgarray [I] = imgarray [num])
{$ ("Curnum"). innerhtml = I + 1 ;}
}
VaR nextimgobj = new image ();
Nextimgobj. src = imgarray [num];
VaR nextimgobj2 = new image ();
Nextimgobj2.src = imgarray [num-1];
$ ("Cover"). innerhtml = "";
$ ("Loading"). style. Display = "Block ";
// IE
VaR appname = navigator. appname. tolowercase ();
If (appname. indexof ("Netscape") =-1)
{
If (nextimgobj. readystate = "complete ")
{
Imgready (event, nextimgobj );
Fadein (nextimgobj );
}
Nextimgobj. onreadystatechange = function (){
If (nextimgobj. readystate = "complete ")
{

Imgready (event, nextimgobj );
Fadein (nextimgobj );
}
};
}
Else {
// FF
Nextimgobj. onload = function (){
If (this. Complete = true ){
Imgready (event, nextimgobj );
Fadein (nextimgobj)
}

}
}
}
Ready (function (){
VaR nextimgobj = new image ();
Nextimgobj. src = imgarray [num];
VaR nextimgobj2 = new image ();
Nextimgobj2.src = imgarray [num + 1];
$ ("Loading"). style. Display = "Block ";
// IE
VaR appname = navigator. appname. tolowercase ();
If (appname. indexof ("Netscape") =-1)
{
If (nextimgobj. readystate = "complete ")
{
$ ("Loading"). style. Display = "NONE ";
$ ("Cover"). innerhtml = "";
$ ("Cover"). appendchild (nextimgobj );

Fadein (nextimgobj );
$ ("Cover"). onmousemove = function (event ){
VaR event = event | window. event;
Nextimgobj. style. Left =-event. clientx * (nextimgobj. width-this.offsetWidth)/This. offsetwidth) + "PX ";
Nextimgobj. style. Top =-event. clienty * (nextimgobj. height-this.offsetHeight)/This. offsetheight) + "PX ";
}
}
Nextimgobj. onreadystatechange = function (){
If (nextimgobj. readystate = "complete ")
{

$ ("Loading"). style. Display = "NONE ";
$ ("Cover"). innerhtml = "";
$ ("Cover"). appendchild (nextimgobj );

Fadein (nextimgobj );
$ ("Cover"). onmousemove = function (event ){
VaR event = event | window. event;
Nextimgobj. style. Left =-event. clientx * (nextimgobj. width-this.offsetWidth)/This. offsetwidth) + "PX ";
Nextimgobj. style. Top =-event. clienty * (nextimgobj. height-this.offsetHeight)/This. offsetheight) + "PX ";
}

}
};
}
Else {
Nextimgobj. onload = function (){
If (this. Complete = true ){
$ ("Loading"). style. Display = "NONE ";
$ ("Cover"). innerhtml = "";
$ ("Cover"). appendchild (nextimgobj );

Fadein (nextimgobj );
$ ("Cover"). onmousemove = function (event ){
VaR event = event | window. event;
Nextimgobj. style. Left =-event. clientx * (nextimgobj. width-this.offsetWidth)/This. offsetwidth) + "PX ";
Nextimgobj. style. Top =-event. clienty * (nextimgobj. height-this.offsetHeight)/This. offsetheight) + "PX ";
}
}

}
}

});
</SCRIPT>
</Body>
</Html>

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.