JavaScript auto scroll RSS feed loop gets slower after running certain time
Hi,
I have a JavaScript auto scroll RSS feed page, that runs fine but it gets/responds very slow after running 24+ hours. Not sure what is the best way to create this kind of page that could run at least few months without any issue?
Detail info if that helps:
I'm using a CNN RSS feed and using rssdog.com to parse data. I have a decent shared web hosting. I'm using Firefox on a windows 7 PC with 2GB of RAM. This PC is going to run 24/7 only for a feed for 3 months.
Please let me know if there is any better way to handle this? Thanks so much (in advance)!
//change 1 to another integer to alter the scroll speed. Greater is faster
var speed=1
var currentpos=0,alt=1,curpos1=0,curpos2=-1
function initialize(){
startit()
}
function iecompattest(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}
function scrollwindow(){
if (document.all)
temp=iecompattest().scrollTop
else
temp=window.pageYOffset
if (alt==0)
alt=1
else
alt=0
if (alt==0)
curpos1=temp
else
curpos2=temp
if (curpos1!=curpos2){
if (document.all)
currentpos=iecompattest().scrollTop+speed
else
currentpos=window.pageYOffset+speed
window.scroll(0,currentpos)
}
else{
currentpos=0
window.scroll(0,currentpos)
}
}
function startit(){
setInterval("scrollwindow()",50)
}
window.onload=initialize
</script>
Logic Ali,
This time it worked well without any problem. Thanks so much.
One more question: Do you think this script might cause Firefox throwing script error/warning message (e.g. a script on this page may be busy...) if I keep running this for few months non-stop? If yes, then what are the other options to parse and display RSS feeds?
Bookmarks