Automatic Image switch-JavaScript 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"> <br/> <HTML xmlns = "http://www.w3.org/1999/xhtml"> <br/> <pead> <br/> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8 "/> <br/> <title> popular products </title> <br/> <MCE: style type =" text/CSS "> <! -- <Br/>/* reset style */<br/> * {margin: 0; padding: 0; Word-break: Break-all ;} <br/> body {Background: # cccccc; color: # cccccc; Font: 12px/1.6em Helvetica, Arial, sans-serif;} <br/> H1, H2, H3, h4, H5, H6 {font-size: 1em ;}< br/> A {color: #039; text-Decoration: None ;}< br/>: hover {text-Decoration: underline ;}< br/> ul, Li {list-style: None ;}< br/> fieldset, IMG {border: none ;} <br/> em, strong, cit E, Th {font-style: normal; font-weight: normal;} <br/>/* focus_change style */<br/> # focus_change {position: relative; width: pixel PX; Height: 295px; overflow: hidden; margin: 10px 0 1px 10px ;}< br/># focus_change_list {position: absolute; width: 1800px; Height: 295px ;} <br/> # focus_change_list Li {float: Left ;}< br/> # focus_change_list Li IMG {width: pixel PX; Height: 295px ;}< br/>. focus_change_opacity {Position: absolute; width: pixel PX; Height: 70px; top: 225px; left: 0; Background: #000; filter: alpha (opacity = 50);-moz-opacity: 0.5; opacity: 0.5 ;}< br/> # focus_change_btn {position: absolute; width: pixel PX; Height: 65px; top: 225px; left: 0 ;} <br/> # focus_change_btn ul {padding-left: 5px ;}< br/> # focus_change_btn Li {display: inline; float: Left; margin: 0 15px; padding-top: 12px ;}< br/> # focus_change_btn Li IMG {width: 76px; Height: 50px; Border: 2px solid #888 ;}< br/># focus_change_btn. current {Background: URL (img/hotgoods.jpg) No-repeat 37px 8px;} <br/> # focus_change_btn. current IMG {border-color: # Eee ;}< br/> --> </MCE: style> <style type = "text/CSS" mce_bogus = "1">/* reset style */<br/> * {margin: 0; padding: 0; word-break: Break-All ;}< br/> body {Background: # cccccc; color: # cccccc; Font: 12px/1.6em Helvetica, Arial, sans-serif ;}< br/> H1, H2, H3, H4, H5, H6 {font-size: 1em ;}< br/> A {color: #039; text-Decoration: None ;}< br/> A: hover {text-Decoration: underline ;}< br/> ul, Li {list-style: none ;} <br/> fieldset, IMG {border: None ;}< br/> em, strong, cite, Th {font-style: normal; font-weight: normal ;} <br/>/* focus_change style */<br/> # focus_change {position: relative; width: pixel; Height: 295 Px; overflow: hidden; margin: 10px 0 1px 10px ;}< br/># focus_change_list {position: absolute; width: 1800px; Height: 295px ;} <br/> # focus_change_list Li {float: Left ;}< br/> # focus_change_list Li IMG {width: pixel PX; Height: 295px ;}< br/>. focus_change_opacity {position: absolute; width: pixel PX; Height: 70px; top: 225px; left: 0; Background: #000; filter: alpha (opacity = 50 ); -Moz-opacity: 0.5; opacity: 0.5 ;} <Br/> # focus_change_btn {position: absolute; width: pixel PX; Height: 65px; top: 225px; left: 0 ;}< br/> # focus_change_btn ul {padding-left: 5px ;}< br/># focus_change_btn Li {display: inline; float: Left; margin: 0 15px; padding-top: 12px ;} <br/> # focus_change_btn Li IMG {width: 76px; Height: 50px; Border: 2px solid #888 ;}< br/> # focus_change_btn. current {Background: URL (img/hotgoods.jpg) No-repeat 37px 8px ;}< br/> # focus_change_btn. current IMG {border-color: # Eee ;}</style> <br/> <MCE: Script Type = "text/JavaScript"> <! -- <Br/> function $ (ID) {return document. getelementbyid (ID) ;}< br/> function moveelement (elementid, final_x, final_y, interval) {<br/> If (! Document. getelementbyid) return false; <br/> If (! Document. getelementbyid (elementid) return false; <br/> var ELEM = document. getelementbyid (elementid); <br/> If (ELEM. movement) {<br/> cleartimeout (ELEM. movement); <br/>}< br/> If (! ELEM. style. Left) {<br/> ELEM. style. Left = "0px"; <br/>}< br/> If (! ELEM. style. top) {<br/> ELEM. style. top = "0px"; <br/>}< br/> var xpos = parseint (ELEM. style. left); <br/> var ypos = parseint (ELEM. style. top); <br/> If (xpos = final_x & ypos = final_y) {<br/> return true; <br/>}< br/> If (xpos <final_x) {<br/> var Dist = math. ceil (final_x-xpos)/10); <br/> xpos = xpos + dist; <br/>}< br/> If (xpos> final_x) {<br/> var Dist = math. ceil (xpos-final_x )/ 10); <br/> xpos = xpos-Dist; <br/>}< br/> If (ypos <final_y) {<br/> var Dist = math. ceil (final_y-ypos)/10); <br/> ypos = ypos + dist; <br/>}< br/> If (ypos> final_y) {<br/> var Dist = math. ceil (ypos-final_y)/10); <br/> ypos = ypos-Dist; <br/>}< br/> ELEM. style. left = xpos + "PX"; <br/> ELEM. style. top = ypos + "PX"; <br/> var repeat = "moveelement ('" + elementid + "'," + final_x + "," + Fina Rochelle y + "," + interval + ")"; <br/> ELEM. movement = setTimeout (Repeat, interval); <br/>}< br/> function classnormal () {<br/> var focusbtnlist = $ ('focus _ change_btn '). getelementsbytagname ('lil'); <br/> for (VAR I = 0; I <focusbtnlist. length; I ++) {<br/> focusbtnlist [I]. classname = ''; <br/>}< br/> function focuschange () {<br/> var focusbtnlist =$ ('focus _ change_btn '). getelementsbytagname ('lil'); <br/> focus Btnlist [0]. onmouseover = function () {<br/> moveelement ('focus _ change_list ', 0, 0, 5); <br/> classnormal () <br/> focusbtnlist [0]. classname = 'current' <br/>}< br/> focusbtnlist [1]. onmouseover = function () {<br/> moveelement ('focus _ change_list ',-values, 0, 5); <br/> classnormal () <br/> focusbtnlist [1]. classname = 'current' <br/>}< br/> focusbtnlist [2]. onmouseover = function () {<br/> moveelement ('focus _ Chan Ge_list ',-900,0, 5); <br/> classnormal () <br/> focusbtnlist [2]. classname = 'current' <br/>}< br/> focusbtnlist [3]. onmouseover = function () {<br/> moveelement ('focus _ change_list ',-1350,0, 5); <br/> classnormal () <br/> focusbtnlist [3]. classname = 'current' <br/>}< br/> setinterval ('autofocuschange () ', 5000); <br/> var atuokey = false; <br/> function autofocuschange () {<br/> $ ('focus _ change '). onmou Seover = function () {atuokey = true} <br/> $ ('focus _ change '). onmouseout = function () {atuokey = false} <br/> If (atuokey) return; <br/> var focusbtnlist = $ ('focus _ change_btn '). getelementsbytagname ('lil'); <br/> for (VAR I = 0; I <focusbtnlist. length; I ++) {<br/> If (focusbtnlist [I]. classname = 'current') {<br/> var currentnum = I; <br/>}< br/> If (currentnum = 0) {<br/> moveelement ('focus _ Cha Nge_list ',-values, 0, 5); <br/> classnormal () <br/> focusbtnlist [1]. classname = 'current' <br/>}< br/> If (currentnum = 1) {<br/> moveelement ('focus _ change_list ',-900,0, 5 ); <br/> classnormal () <br/> focusbtnlist [2]. classname = 'current' <br/>}< br/> If (currentnum = 2) {<br/> moveelement ('focus _ change_list ',-1350,0, 5 ); <br/> classnormal () <br/> focusbtnlist [3]. classname = 'current' <br/>}< br/> If (curren Tnum = 3) {<br/> moveelement ('focus _ change_list ', 0, 0, 5); <br/> classnormal () <br/> focusbtnlist [0]. classname = 'current' <br/>}< br/> window. onload = function () {<br/> focuschange (); <br/>}< br/> // --> </MCE: SCRIPT> <br/> </pead> <br/> <body bgcolor = "# cccccc" topmargin = "0"> <br/> <Div id = "focus_change" Style = "background-color: # cccccc "mce_style =" background-color: # cccccc "> <br/> <Div id =" focus_change _ List "style =" Top: 0; left: 0; color: # cccccc "> <br/> <ul> <br/> <li> </LI> <br/> <li> </LI> <br/> <li> </LI> <br/> <li> </LI> <br/> </ul> <br /> </Div> <br/> <Div class = "focus_change_opacity"> </div> <br/> <Div id = "focus_change_btn"> <br/> <ul> <br/> <li class = "current"> <a href = "#" mce_href = "#"> </a> </LI> <br/> <li> <a href =" # "mce_href =" # "> </a> </LI> <br/> <li> <pref = "#" mce_href = "#"> </a> </LI> <br/> <li> <a href =" # "mce_href =" # "> </a> </LI> <br/> </ul> <br/> </div> <br/> <! -- Focus_change end --> <br/> </body> <br/> </ptml> <br/>

Over

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.