How To Make Highlighted Scroller Using HTML JavaScript
Submitted by alpha_luna on Friday, July 22, 2016 - 10:15.
In this tutorial, we are going to learn How To Make Highlighted Scroller Using HTML JavaScript. This is a scroller that displays messages by highlighting each one of it.
Just download the full source code below.
Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.
Example
Creating Markup
Just simply add the codes below, to paste it where you want the scroller to appear on your page in your BODY tag.Creating Script
Kindly copy this simple script below your HTML source code to execute the markup.- <script language="JavaScript">
- var tickercontents=new Array()
- tickercontents[0]='Looking for source code and resources? Visit <a href="http://sourcecodester.com">sourcecodester.com</a>'
- tickercontents[1]='Thank you for downloading the source code.'
- tickercontents[2]='For more tutorial, click <a href="http://www.sourcecodester.com/tutorial">here</a>.'
- var tickdelay=3000
- var highlightspeed=10
- var currentmessage=0
- var clipwidth=0
- function changetickercontent(){
- crosstick.style.clip="rect(0px 0px auto 0px)"
- crosstick.innerHTML=tickercontents[currentmessage]
- highlightmsg()
- }
- function highlightmsg(){
- var msgwidth=crosstick.offsetWidth
- if (clipwidth<msgwidth){
- clipwidth+=highlightspeed
- crosstick.style.clip="rect(0px "+clipwidth+"px auto 0px)"
- beginclip=setTimeout("highlightmsg()",20)
- }
- else{
- clipwidth=0
- clearTimeout(beginclip)
- if (currentmessage==tickercontents.length-1) currentmessage=0
- else currentmessage++
- setTimeout("changetickercontent()",tickdelay)
- }
- }
- function start_ticking(){
- crosstick=document.getElementById? document.getElementById("highlighter") : document.all.highlighter
- crosstickParent=crosstick.parentNode? crosstick.parentNode : crosstick.parentElement
- if (parseInt(crosstick.offsetHeight)>0)
- crosstickParent.style.height=crosstick.offsetHeight+'px'
- else
- setTimeout("crosstickParent.style.height=crosstick.offsetHeight+'px'",100)
- changetickercontent()
- }
- if (document.all || document.getElementById)
- window.onload=start_ticking
- </script>
Add new comment
- 21 views