You can perform regular operations for js image effects.

Source: Internet
Author: User

Copy codeThe Code is as follows:
<% @ Page language = "java" import = "java. util. *" pageEncoding = "ISO-8859-1" %>
<%
String path = request. getContextPath ();
String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/";
%>

<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Base href = "<% = basePath %>">

<Title> My JSP 'tu. jsp 'starting page </title>

<Meta http-equiv = "pragma" content = "no-cache">
<Meta http-equiv = "cache-control" content = "no-cache">
<Meta http-equiv = "expires" content = "0">
<Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
<Meta http-equiv = "description" content = "This is my page">
<Style type = "text/css">
*{
Margin: 0px;
Padding: 0px;
}
Li {
List-style: none;
}
Img {
Border: 0;
}
A {
Text-decoration: none;
}
# Slide {
Width: 800px;
Height: 400px;
Box-shadow: 0px 0px 5px # c1c1c1;
Margin: 20px auto;
Position: relative;
Overflow: hidden;
}
# Slide ul {
Position: absolute;
Left: 0px;
Top: 0px;
Height: 400px;
Width: 11930px;
}
# Slide ul li {
Width: 800px;
Height: 400px;
Overflow: hidden;
Float: left;
}
# Slide. ico {
Width: 800px;
Height: 20px;
Overflow: hidden;
Text-align: center;
Position: absolute;
Left: 0px;
Bottom: 10px;
Z-index: 1;
}
# Slide. ico {
Display: inline-block;
Width: 10px;
Height: 10px;
Background: url(out.png) no-repeat 0px 0px;
Margin: 0px 5px;
}
# Slide. ico. active {
Background: url(out1.png) no-repeat 0px 0px;
}
# BtnLeft {
Width: 60px;
Height: 400px;
Left: 0px;
Top: 0px;
Background: url () no-repeat 0px 0px;
Position: absolute;
Z-index: 2;
}
# BtnLeft: hover {
Background: url () no-repeat 0px 0px;
}
# BtnRight {
Width: 60px;
Height: 400px;
Right: 0px;
Top: 0px;
Background: url () no-repeat 0px 0px;
Position: absolute;
Z-index: 2;
}
# BtnRight: hover {
Background: url () no-repeat 0px 0px;
}

</Style>

<Script type = "text/javascript">
Window. onload = function (){
Var oIco = document. getElementById ("ico ");
Var aBtn = oIco. getElementsByTagName ("");
Var oSlide = document. getElementById ("slide ");
Var oUl = oSlide. getElementsByTagName ("ul ");
Var aLi = oUl [0]. getElementsByTagName ("li ");
Var oBtnLeft = document. getElementById ("btnLeft ");
Var oBtnRight = document. getElementById ("btnRight ");

Var baseWidth = aLi [0]. offsetWidth;
// Alert (baseWidth );
OUl [0]. style. width = baseWidth * aLi. length + "px ";
Var iNow = 0;
For (var I = 0; I <aBtn. length; I ++ ){
ABtn [I]. index = I;
ABtn [I]. onclick = function (){
// Alert (this. index );
// Alert (oUl [0]. style. left );
Move (this. index );
// AIco [this. index]. className = "active ";
}
}
OBtnLeft. onclick = function (){
INow ++;
// Document. title = iNow;
Move (iNow );
}
OBtnRight. onclick = function (){
INow --;
Document. title = iNow;
Move (iNow );
}

Var curIndex = 0;
Var timeInterval = 1000;
SetInterval (change, timeInterval );
Function change (){
If (curIndex = aBtn. length ){
CurIndex = 0;
} Else {
Move (curIndex );
CurIndex + = 1;
}

}

Function move (index ){
// Document. title = index;
If (index> aLi. length-1 ){
Index = 0;
INow = index;
}
If (index <0 ){
Index = aLi. length-1;
INow = index;
}
For (var n = 0; n <aBtn. length; n ++ ){
ABtn [n]. className = "";
}
ABtn [index]. className = "active ";
OUl [0]. style. left =-index * baseWidth + "px ";
// Buffer (oUl [0], {
// Left:-index * baseWidth
//}, 8)

}
}
</Script>
</Head>
<Body>
<Div id = "slide">
<A id = "btnLeft" href = "javascript: void (0);"> </a>
<A id = "btnRight" href = "javascript: void (0);"> </a>
<! -- When change next image: style = "left:-(n-1) * 800px;" -->
<Ul>
<Li> </li>
<Li> </li>
<Li> </li>
<Li> </li>
</Ul>
<Div id = "ico" class = "ico">
<A class = "active" href = "javascript: void (0);"> </a>
<A href = "javascript: void (0);"> </a>
<A href = "javascript: void (0);"> </a>
<A href = "javascript: void (0);"> </a>
<A href = "javascript: void (0);"> </a>
<A href = "javascript: void (0);"> </a>
</Div>
</Div>
</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.