This is more of a feature request than problem. I may eventually add such an ability to the script; in the meantime, the best I can do is give you an idea of how to do this. Firstly, replace the original rotatemsg() function inside the script with the below instead:
Code:
ajax_ticker.prototype.rotatemsg=function(){
var instanceOfTicker=this
if (this.mouseoverBol==1) //if mouse is currently over ticker, do nothing (pause it)
this.pausetimer=setTimeout(function(){instanceOfTicker.rotatemsg()}, 100)
else{ //else, construct item, show and rotate it!
this.fadetransition("reset") //FADE EFFECT- RESET OPACITY
this.contentdiv.innerHTML=this.messages[this.pointer]
this.fadetimer1=setInterval(function(){instanceOfTicker.fadetransition('up', 'fadetimer1')}, 100) //FADE EFFECT- PLAY IT
this.pointer=(this.pointer<this.messages.length-1)? this.pointer+1 : 0
this.rotatetimer=setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) //update container periodically
}
}
The parts in red are now, basically adding identifiers to the timers used by the function, to cancel them before refreshing the script. Then, for the script on your HTML page itself, you may have something like:
Code:
<script type="text/javascript">
var xmlfile="tickercontent.txt" //path to ticker txt file on your server.
//ajax_ticker(xmlfile, divId, divClass, delay, optionalfadeornot)
var myticker=new ajax_ticker(xmlfile, "ajaxticker1", "someclass", 3500, "fade")
</script>
<script type="text/javascript">
function updatesource(){
clearTimeout(myticker.rotatetimer)
clearTimeout(myticker.fadetimer1)
clearTimeout(myticker.pausetimer)
document.getElementById(myticker.tickerid).firstChild.innerHTML="refreshing contents..."
myticker.getXMLfile()
}
//refresh ticker source every 4 seconds
setInterval("updatesource()", 4000)
</script>
Bookmarks