...

View Full Version : Highlighter Roller Script



tingtejs
09-09-2008, 02:34 PM
I have this script working and would like to center the output since not all the text arrays take up the full alloted space. I tried playing around with the <span style> & <div> tags with no luck. Can anyone help with this ?

<div style="position:relative;left:0px;top:0px">
<span id="highlighter" style="position:absolute;left:0;top:0;font-size:18px;font-family:Verdana;background-color:yellow;clip:rect(0px 0px auto 0px)"></span>
</div>

<script type="text/javascript">

/*
Highligher Scroller script- By JavaScript Kit
For this and over 400+ free scripts, visit http://www.javascriptkit.com/
This notice must stay intact
*/

var tickercontents=new Array()
tickercontents[0]='Looking for free Java applets and resources? Visit <a href="http://freewarejava.com">Freewarejava.com</a>!'
tickercontents[1]='Hop on over to <a href="http://www.codingforums.com">Coding Forums</a> to get help on web coding!'
tickercontents[2]='This scroller\'s brought to you by <a href="http://www.javascriptkit.com">JavaScript Kit</a>'

var tickdelay=3000 //delay btw messages
var highlightspeed=10 //10 pixels at a time.

////Do not edit pass this line////////////////

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) //delay for Mozilla's sake
changetickercontent()
}

if (document.all || document.getElementById)
window.onload=start_ticking

</script>

<p align="left">This free script provided by<br />
<a href="http://javascriptkit.com">JavaScript Kit</a></p>

jeremysnyder
09-09-2008, 07:34 PM
If you change the <span> into a <p> and add the following to the style...

width: 100%;text-align: center;

so that it looks like the following, then I believe you will get what you are asking for.


<div style="position:relative;left:0px;top:0px;">
<p id="highlighter" style="width: 100%;text-align: center;position:absolute;left:0;top:0;font-size:18px;font-family:Verdana;background-color:yellow;clip:rect(0px 0px auto 0px)"></p>
</div>

Jeremy Snyder
http://snydersoft.com

tingtejs
09-10-2008, 09:10 AM
Works perfectly FF, IE, OP. Thanks so much.
Never thought of the "<p> tag.

tingtejs
09-11-2008, 09:47 AM
oops

now the text is centered but goes blank between messages instead of going from one message to the next without a gap like it did before. Is there another way to center the message ?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum