Scroll up/down

Source: Internet
Author: User
Tip: you can modify some code before running

<!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><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>Untitled Document</title><script type="text/javascript">Function Marquee () {this. ID = document. getElementById (arguments [0]); if (! This. ID) {alert ("The \" you want to set "+ arguments [0] +" \ "initialization error \ r \ n please check whether the tag ID settings are correct! "); This. ID =-1; return;} this. direction = this. width = this. height = this. delayTime = this. waitTime = this. CTL = this. startID = this. stop = this. mouseOver = 0; this. step = 1; this. timer = 30; this. direarray array = {"top": 0, "up": 0, "bottom": 1, "down": 1, "left": 2, "right": 3 }; if (typeof arguments [1] = "number" | typeof arguments [1] = "string") this. direction = arguments [1]; if (typeof arguments [2] = "Number") this. step = arguments [2]; if (typeof arguments [3] = "number") this. width = arguments [3]; if (typeof arguments [4] = "number") this. height = arguments [4]; if (typeof arguments [5] = "number") this. timer = arguments [5]; if (typeof arguments [6] = "number") this. delayTime = arguments [6]; if (typeof arguments [7] = "number") this. waitTime = arguments [7]; if (typeof arguments [8] = "number") this. scrollStep = Arguments [8]; this. ID. style. overflow = this. ID. style. overflowX = this. ID. style. overflowY = "hidden"; this. ID. noWrap = true; this. isNotOpera = (navigator. userAgent. toLowerCase (). indexOf ("opera") =-1); if (arguments. length> = 7) this. start ();} Marquee. prototype. start = function () {if (this. ID =-1) return; if (this. waitTime <800) this. waitTime = 800; if (this. timer <20) this. timer = 20; if (this. width = 0) this . Width = parseInt (this. ID. style. width); if (this. height = 0) this. height = parseInt (this. ID. style. height); if (typeof this. direction = "string") this. direction = this. direarray array [this. direction. toString (). toLowerCase ()]; this. halfWidth = Math. round (this. width/2); this. halfHeight = Math. round (this. height/2); this. bakStep = this. step; this. ID. style. width = this. width + "px"; this. ID. style. height = thi S. Height + "px"; if (typeof this. ScrollStep! = "Number") this. ScrollStep = this. Direction> 1? This. Width: this. Height; var templateTop ="<table cellspacing='0' cellpadding='0' ><tr><td noWrap=true >MSCLASS_TEMP_HTML</td><td noWrap=true >MSCLASS_TEMP_HTML</td></tr></table>"; Var templateTop ="<table cellspacing='0' cellpadding='0' ><tr><td>MSCLASS_TEMP_HTML</td></tr><tr><td>MSCLASS_TEMP_HTML</td></tr></table>"; Var msobj = this; msobj. tempHTML = msobj. ID. innerHTML; if (msobj. direction <= 1) {msobj. ID. innerHTML = templateTop. replace (/MSCLASS_TEMP_HTML/g, msobj. ID. innerHTML);} else {if (msobj. scrollStep = 0 & msobj. delayTime = 0) {msobj. ID. innerHTML + = msobj. ID. innerHTML;} else {msobj. ID. innerHTML = templateLeft. replace (/MSCLASS_TEMP_HTML/g, msobj. ID. innerHTML) ;}} var timer = this. timer; var delaytime = this. delayTi Me; var waittime = this. waitTime; msobj. startID = function () {msobj. scroll ()} msobj. continue = function () {if (msobj. mouseOver = 1) {setTimeout (msobj. continue, delaytime);} else {clearInterval (msobj. timerID); msobj. CTL = msobj. stop = 0; msobj. timerID = setInterval (msobj. startID, timer) ;}} msobj. pause = function () {msobj. stop = 1; clearInterval (msobj. timerID); setTimeout (msobj. continue, delaytime);} msobj. begin = fu Nction () {msobj. ClientScroll = msobj. Direction> 1? Msobj. ID. scrollWidth/2: msobj. ID. scrollHeight/2; if (msobj. direction <= 1 & msobj. clientScroll <= msobj. height + msobj. step) | (msobj. direction> 1 & msobj. clientScroll <= msobj. width + msobj. step) {msobj. ID. innerHTML = msobj. tempHTML; delete (msobj. tempHTML); return;} delete (msobj. tempHTML); msobj. timerID = setInterval (msobj. startID, timer); if (msobj. scrollStep <0) return; msobj. ID. onmousemove = f Unction (event) {if (msobj. scrollStep = 0 & msobj. direction> 1) {var event = event | window. event; if (window. event) {if (msobj. isNotOpera) {msobj. eventTop = event. srcElement. id = msobj. ID. id? Event. offsetY-msobj. ID. scrollTop: event. srcElement. offsetTop-msobj. ID. scrollTop + event. offsetY;} else {msobj. scrollStep = null; return ;}} else {msobj. eventTop = event. layerY-msobj. ID. scrollTop;} msobj. direction = msobj. eventTop> msobj. halfHeight? 3: 2; msobj. absCenter = Math. abs (msobj. halfHeight-msobj. eventTop); msobj. step = Math. round (msobj. absCenter * (msobj. bakStep * 2)/msobj. halfHeight) ;}} msobj. ID. onmouseover = function () {if (msobj. scrollStep = 0) return; msobj. mouseOver = 1; clearInterval (msobj. timerID);} msobj. ID. onmouseout = function () {if (msobj. scrollStep = 0) {if (msobj. step = 0) msobj. step = 1; return;} msobj. mouseOver = 0; if (msobj. stop = 0) {clearInterval (msobj. timerID); msobj. timerID = setInterval (msobj. startID, timer) ;}} setTimeout (msobj. begin, waittime);} Marquee. prototype. scroll = function () {switch (this. direction) {case 0: this. CTL + = this. step; if (this. CTL> = this. scrollStep & this. delayTime> 0) {this. ID. scrollTop + = this. scrollStep + this. step-this. CTL; this. pause (); return;} else {if (this. ID. scrollTop> = this. clientScroll) {this. ID. scrollTop-= this. clientScroll;} this. ID. scrollTop + = this. step;} break; case 1: this. CTL + = this. step; if (this. CTL> = this. scrollStep & this. delayTime> 0) {this. ID. scrollTop-= this. scrollStep + this. step-this. CTL; this. pause (); return;} else {if (this. ID. scrollTop <= 0) {this. ID. scrollTop + = this. clientScroll;} this. ID. scrollTop-= this. step;} break; case 2: this. CTL + = this. step; if (this. CTL> = this. scrollStep & this. delayTime> 0) {this. ID. scrollTop + = this. scrollStep + this. step-this. CTL; this. pause (); return;} else {if (this. ID. scrollTop> = this. clientScroll) {this. ID. scrollTop-= this. clientScroll;} this. ID. scrollTop + = this. step;} break; case 3: this. CTL + = this. step; if (this. CTL> = this. scrollStep & this. delayTime> 0) {this. ID. scrollTop-= this. scrollStep + this. step-this. CTL; this. pause (); return;} else {if (this. ID. scrollTop <= 0) {this. ID. scrollTop + = this. clientScroll;} this. ID. scrollTop-= this. step;} break;} // --></script></head><body><div id="marqueediv1" ></div><input type="button" value="向上" id="top0"> <input type="button" value="向下" id="bottom1"><script type="text/javascript">Var marquee3 = new Marquee ("marqueediv1"); marquee3.Direction = "top"; marquee3.Step = 1; marquee3.Width = 632; marquee3.Height = 52; marquee3.Timer = 5; limit = 1; // disable the mouse control of marquee3.Start (); var top0 = document. getElementById ("top0"); // This sentence control is compatible with FFvar bottom1 = document. getElementById ("bottom1"); // This sentence control is compatible with FFtop0.onmouseover = function () {marquee3.Direction = 2} top0.onmouseout = top0.onmouseup = function () {marquee3.Step = response} top0.onmousedown = bottom1.onmousedown = function () {marquee3.Step = response + 2} bottom1.onmouseover = function () {marquee3.Direction = 3} bottom1.onmouseout = response = function () {marquee3.Step = marquee3.BakStep}</script></body></html>
Tip: you can modify some code before running

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.