JS realize flash slide picture switch effect Method _javascript skill

Source: Internet
Author: User

This article illustrates the method of JS to realize flash slide picture switching effect. Share to everyone for your reference. The implementation methods are as follows:

Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<meta http-equiv= "Content-language" content= "gb2312"/>
<meta name= "Author" content= "Rainoxu"/>
&LT;TITLE&GT;JS analog Flash slide picture toggle effect </title>
<body>
<style type = "Text/css" >
/* <! [cdata[* *
ul,li{
padding:0;
margin:0;
List-style:none;
}
#flashBox {
width:326px;
height:246px;
border:1px solid #EEE;
position:relative;
}
#flashBox img{
/* Initial do not show * *
Display:none;
/* Use a border to achieve the vacancy, because margin and paading sometimes cause some trouble.
BORDER:3PX solid #FFF;
}
#flashBox ul{
Position:absolute;
right:7px;
bottom:9px;
FONT:9PX Tahoma;
}
#flashBox ul li{
Display:block;
Float:left;
width:12px;
height:12px;
line-height:12px;
margin-right:3px;
border:1px solid #999;
Background: #F0F0F0;
Text-align:center;
Cursor:pointer;
}
#flashBox ul li.hover{
border-color:red;
Background: #FFE1E1;
color:red;
}
*]]> * *
</style>
<script type= "Text/javascript" >
function Flashboxctrl (o) {
This.obj=document.getelementbyid (o);
This private method is written, but it is not used for a while
function AddListener (ele,eventname,functionbody) {
if (ele.attachevent) {
Ele.attachevent ("On" +eventname, Functionbody);
}else if (ele.addeventlistener) {
Ele.addeventlistener ("On" +eventname,functionbody, false);
}else{
return false;
}
}
Class
This.init=function () {
var objimg=this.obj.getelementsbytagname ("img");
var taglength=objimg.length;
if (taglength>0) {
var oul=document.createelement ("ul");
Oul.setattribute ("id", o+ "Numtag");
for (Var i=0;i<taglength;i++) {
var oli=oul.appendchild (document.createelement ("Li"));
if (i==0) {
Oli.setattribute ("Class", "hover"); Set the first one to highlight when initializing
Oli.setattribute ("ClassName", "hover");
}
Set the number of labels
Oli.appendchild (document.createTextNode (i+1));
}
This.obj.appendChild (Oul);
objimg[0].style.display= "Block";
Set Label events
var otag=this.obj.getelementsbytagname ("Li");
for (Var i=0;i<otag.length;i++) {
Otag[i].onmouseover=function () {
for (j=0;j<otag.length;j++) {
Otag[j].classname= "";
Objimg[j].style.display= "None";
}
This.classname= "hover";
objimg[this.innerhtml-1].style.display= "Block";
}
}
}
};
The automatic scrolling method hasn't been written yet.
This.imgroll=function () {};
Automatically load the init () method when an object is generated to initialize the object
This.init ();
}
</script>
<div id= "Flashbox" >




</div>
<script type= "Text/javascript" >
Generate an Object
New Flashboxctrl ("Flashbox");
</script>
</body>

I hope this article will help you with your JavaScript programming.

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.