Phiên bản đầy đủ: jsB@nk » Scrollers » Theo chiều ngang » Chữ cuộn từ phải sang
URL: https://www.javascriptbank.com/scrolling-hypertext-ticker.html
Một đoạn mã JavaScript JavaScript khác để tạo hiệu ứng chữ di chuyển">di chuyển trong khung từ phải sang trái.
Phiên bản đầy đủ: jsB@nk » Scrollers » Theo chiều ngang » Chữ cuộn từ phải sang
URL: https://www.javascriptbank.com/scrolling-hypertext-ticker.html
<body onload="init(); banSlide()"><script language="JavaScript"><!--// Hypertext Banner v1.5//Created by Howard Chen, [email protected] = (document.layers) ? 1:0ie = (document.all) ? 1:0if (n) { windowWidth = window.innerWidth-17 windowHeight = window.innerHeight-17 }else if (ie) { windowWidth = document.body.clientWidth-17 windowHeight = document.body.clientHeight-17 }at_center = "(windowWidth-showWidth)/2"at_right = "windowWidth-showWidth"at_left = "0";//================ CONFIGURE YOUR BANNER HERE ======================spd = 20 // speed in msshowWidth = 400 // Width of the banner shown on the screen at one timeshowHeight = 20 // The Height of bannerfromTop = 40 // The banner's position in pixel from the top of the pagefromLeft = eval(at_center) // The banner's position in pixel from the left side of the pageloop = "infinite"; // The number of times this banner will rotate, use "infinite" for infinitly many times.// The text that is to be displayed, HTML tags ARE allowed!!display_text = "JavaScriptBank.com - Bank of over 2000+ free JavaScripts"/* You can use eval(at_center) to place the banner in the center, eval(at_left) to place on the left, or eval(at_right) to place on the right.*///================ DO NOT EDIT CODES BELOW THIS LINE ===========function init() { banner = new dynLayer("banDiv", null, 0, showWidth, showHeight, 0) banner.moveTo(fromLeft,fromTop); if (n) { banner.ref.open(); banner.ref.write("<NOBR>"); for (var i = showWidth/4; i > 0; i--) { banner.ref.write(" "); } banner.ref.write(display_text); banner.ref.write("</NOBR>"); banner.ref.close(); } if (ie) { document.all["banDiv"].innerHTML = "<NOBR>" for (var i = showWidth/4; i > 0; i--) { document.all["banDiv"].innerHTML += " "; } document.all["banDiv"].innerHTML += display_text + "</NOBR>"; } }function dynLayer(id,nestref,ctop,cright,cbottom,cleft) { if (n) { if (nestref) { this.css = eval("document." + nestref + ".document." + id) this.ref = eval("document." + nestref + ".document." + id + ".document") } else { this.css = document.layers[id] this.ref = document.layers[id].document } this.x = this.css.left this.y = this.css.top } else if (ie) { this.css = document.all[id].style this.ref = document this.x = this.css.pixelLeft this.y = this.css.pixelTop } this.obj = id + "Object" eval(this.obj + "=this") this.moveBy = dynLayerMoveBy this.moveTo = dynLayerMoveTo this.clipBy = dynLayerClipBy this.clipTo = dynLayerClipTo this.clipValues = dynLayerClipValues if (ie) { if (ctop!=null && cright!=null && cbottom!=null && cleft!=null) this.clipTo(ctop,cright,cbottom,cleft) else if (this.css.pixelWidth && this.css.pixelHeight) this.clipTo(0,this.css.pixelWidth,this.css.pixelHeight,0) }}function dynLayerMoveBy(x,y) { this.x += x this.css.left = this.x this.y += y this.css.top = this.y}function dynLayerMoveTo(x,y) { this.x = x this.css.left = this.x this.y = y this.css.top = this.y}function dynLayerClipBy(t,r,b,l) { if (n) { this.css.clip.top = this.clipValues('t') + t this.css.clip.right = this.clipValues('r') + r this.css.clip.bottom = this.clipValues('b') + b this.css.clip.left = this.clipValues('l') + l } else if (ie) this.css.clip = "rect("+(this.clipValues('t')+t)+"px "+(this.clipValues('r')+r)+"px "+Number(this.clipValues('b')+b)+"px "+Number(this.clipValues('l')+l)+"px)"}function dynLayerClipTo(t,r,b,l) { if (n) { this.css.clip.top = t this.css.clip.right = r this.css.clip.bottom = b this.css.clip.left = l } else if (ie) this.css.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"}function dynLayerClipValues(which) { if (n) { if (which=="t") return this.css.clip.top if (which=="r") return this.css.clip.right if (which=="b") return this.css.clip.bottom if (which=="l") return this.css.clip.left } else if (ie) { var clipv = this.css.clip.split("rect(")[1].split(")")[0].split("px") if (which=="t") return Number(clipv[0]) if (which=="r") return Number(clipv[1]) if (which=="b") return Number(clipv[2]) if (which=="l") return Number(clipv[3]) }}function banSlide(){var i if (n) { i = banner.css.clip.height }if (ie) { i = banner.css.pixelHeight }banner.moveBy(-2,0)banner.clipBy(0,2,0,2)setTimeout("banSlide()", spd);}document.writeln('<STYLE TYPE="text/css">');document.writeln('<\!--');document.writeln('#banDiv {position:relative; height: 50; clip:rect(0,' + showWidth + ',' + showHeight + ',0)}');document.writeln('-->');document.writeln('</STYLE>');</script><div id="banDiv"></div></body><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->