Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript scrolling question

    Hi everyone,

    Just wondering what i would change to make this scroll from left to right instead of scrolling up?

    Here's the code:

    Code:
    <div id="datacontainer" style="position:absolute;left:1px;top:10px;width:100%" onMouseover="scrollspeed=0" onMouseout="scrollspeed=cache"> 
    
    <!-- ADD YOUR SCROLLER CONTENT INSIDE HERE --> 
    
    Test 
    
    <!-- END SCROLLER CONTENT --> 
    
    </div> 
    
    <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=1 
    
    //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) 
    } 
    
    function getdataheight(){ 
    thelength=dataobj.offsetHeight 
    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,
    Jay

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    change everythignthat has to do with vertical movement to horizontal movement. vertical: top,height horizontal: left, width
    change everythign that says top to left, and everything that says height to width.

    Code:
    <div id="datacontainer" style="position:absolute;left:1px;top:10px;width:100%" onMouseover="scrollspeed=0" onMouseout="scrollspeed=cache"> 
    
    <!-- ADD YOUR SCROLLER CONTENT INSIDE HERE --> 
    
    Test 
    
    <!-- END SCROLLER CONTENT --> 
    
    </div> 
    
    <script type="text/javascript"> 
    
    //Specify speed of scroll. Larger=faster (ie: 5) 
    var scrollspeed=cache=1 
    
    //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("getdataWidth()", initialdelay) 
    } 
    
    function getdataWidth(){ 
    theWidth=dataobj.offsetWidth 
    if (theWidth==0) 
    setTimeout("getdataWidth()",10) 
    else 
    scrollDiv() 
    } 
    
    function scrollDiv(){ 
    dataobj.style.left=parseInt(dataobj.style.left)-scrollspeed+"px" 
    if (parseInt(dataobj.style.left)<theWidth*(-1)) 
    dataobj.style.left="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>
    Last edited by brandonH; 11-04-2006 at 09:02 AM. Reason: correction
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #3
    New Coder
    Join Date
    Aug 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, Thank you.


  •  

    Posting Permissions

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