Results 1 to 1 of 1

Thread: Issue with IFrame scroller script

  1. #1
    Join Date
    May 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Issue with IFrame scroller script

    1) Script Title: Top-Down scrolling window script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/topscroll.htm

    3) Describe problem:
    I need help... my javascript skills are sadly lacking...
    The feed for my IFRame is a sql extract populating the display that scrolls... this works... but the length of this feed is variable and I need to be able to refresh this data at the end of each scroll.

    I have a javascript function that is called to refresh the data and I placed it in the Initialization function... but it doesn't appear to adjust the settimeout call to start the refresh function as the document length changes...

    The line I added is setTimeout("reLoad()",dataobj.offsetHeight*4);
    the *4 is a swag that seems to work as a multiplier of the document length.

    the problem is that I need to adjust this length as the document shortens.

    any help would be appreciated as I seem to be floundering...

    Code:
            <script type="text/javascript">
    
            /***********************************************
            * IFRAME Scroller script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
            * This notice MUST stay intact for legal use
            * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
            ***********************************************/
    
            //Specify speed of scroll. Larger=faster (ie: 5)
            var scrollspeed=cache=2
    
            //Specify intial delay before scroller starts scrolling (in miliseconds):
            var initialdelay=500
    
            function initializeScroller(){
                dataobj=document.all? document.all.datacontainer : document.getElementById("datacontainer")
                dataobj.style.top="5px"
                setTimeout("getdataheight()", initialdelay)
                setTimeout("reLoad()",dataobj.offsetHeight*4);
            }
    
            function getdataheight(){
                thelength=dataobj.offsetHeight
                document.getElementById("lbl_ScrollRefresh").innerHTML = thelength;
                if (thelength==0)
                    setTimeout("getdataheight()",10)
                else
                    scrollDiv()
            }
    
            function scrollDiv(){
                dataobj.style.top=parseInt(dataobj.style.top)-scrollspeed+"px"
                if (parseInt(dataobj.style.top)<thelength*(-1))
                    dataobj.style.top="5px"
                    setTimeout("scrollDiv()",40)
            }
    
            if (window.addEventListener)
                window.addEventListener("load", initializeScroller, false)
            else if (window.attachEvent)
                window.attachEvent("onload", initializeScroller)
            else
                window.onload=initializeScroller
    
            </script>
    Thanks Jim-
    Last edited by jscheuer1; 05-16-2012 at 11:59 PM. Reason: Format

Bookmarks

Posting Permissions

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