www.webdeveloper.com
Results 1 to 4 of 4

Thread: JavaScript auto scroll RSS feed loop gets slower after running certain time

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    4

    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?

    Example: RSS feed auto scroll loop

    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)!

    Code:
    <!DOCTYPE html>
    <HTML>
    <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
    <META HTTP-EQUIV="REFRESH" CONTENT="900">
    <TITLE>RSS feed autoscroll loop</TITLE>
    <META NAME="description" CONTENT="">
    <meta name="robots" content="index,nofollow" />
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />

    <STYLE TYPE="text/css">
    body,html {
    min-height:100%; /*Firefox scrollbar fix*/
    }
    a, a:visited, a:hover, a:active {
    color:#333;
    text-decoration: none;
    display: block;
    padding-bottom: 12px;
    margin-top: 10px;;
    }
    #top-stories {
    font-family: 'Helvetica', Verdana, sans-serif;
    font-size: 1.5em;
    font-weight: bolder;
    text-align: left;
    line-height: 1.2em;
    margin: 0px 15px 0px 15px;
    }
    </STYLE>
    </HEAD>

    <BODY>
    <script language="JavaScript1.2">

    /*
    Top-Down scrolling window Script- Dynamic Drive (www.dynamicdrive.com)
    For full source code, visit http://www.dynamicdrive.com
    This notice MUST stay intact for use
    */

    //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>

    <div id="top-stories">
    <script type="text/javascript" language="javascript" src="http://www.rssdog.com/index.htm?url=http%3A%2F%2Frss.cnn.com%2Frss%2Fedition.rss&amp;mode=javascript&amp;showonly=&amp;max items=500&amp;showdescs=1&amp;desctrim=0&amp;descmax=0&amp;tabwidth=100%25&amp;excltitle=1&amp;linkt arget=_blank&amp;bordercol=%23d4d0c8&amp;headbgcol=%23999999&amp;headtxtcol=%23ffffff&amp;titlebgcol =%23f1eded&amp;titletxtcol=%23000000&amp;itembgcol=%23ffffff&amp;itemtxtcol=%23000000&amp;ctl=0">
    </script>
    </div>

    </BODY>
    </HTML>

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Perhaps content is expiring and being reloaded, causing multiple onload events. Try modifying the initialize function as follows:
    Code:
    function initialize()
    {
      window.onload = null;
      startit();
    }

  3. #3
    Join Date
    Feb 2013
    Posts
    4
    Thanks so much Logic Ali. I updated the function and running another test for next 24 hours. Let's see how it works. Thanks again!

  4. #4
    Join Date
    Feb 2013
    Posts
    4
    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?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles