Results 1 to 4 of 4

Thread: Ability to disable DynamicDrive.com's Custom Scrollbar

  1. #1
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Ability to disable DynamicDrive.com's Custom Scrollbar

    Hi There,

    I'm currently testing out the custom scrollbar that I found on this site.

    I think it works terrific, how ever I would like to hide the scroller when the page can't scrolled.

    I.E., if a page can't be scrolled then I don't want the scroller to be hidden?

    Here is the code as it is at the moment:

    Code:
    <html>
    
    <body>
    
    <div id="staticbuttons" style="position:absolute;">
    <a href="javascript:" onmouseover="myspeed=-thespeed" onmouseout="myspeed=0"><img
    src="arrows_up.gif" border="0"></a><br>
    <a href="javascript:" onmouseover="myspeed=thespeed" onmouseout="myspeed=0"><img
    src="arrows_dn.gif" border="0"></a>
    </div>
    
    <script>
    
    //Page Scroller (aka custom scrollbar)- By Dynamic Drive
    //For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
    //This credit MUST stay intact for use
    
    var Hoffset=70 //Enter buttons' offset from right edge of window (adjust depending on images width)
    var Voffset=80 //Enter buttons' offset from bottom edge of window (adjust depending on images height)
    var thespeed=3 //Enter scroll speed in integer (Advised: 1-3)
    
    var ieNOTopera=document.all&&navigator.userAgent.indexOf("Opera")==-1
    var myspeed=0
    
    var ieHoffset_extra=document.all? 15 : 0
    var cross_obj=document.all? document.all.staticbuttons : document.getElementById? document.getElementById("staticbuttons") : document.staticbuttons
    
    function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }
    
    function positionit(){
    var dsocleft=document.all? iecompattest().scrollLeft : pageXOffset
    var dsoctop=document.all? iecompattest().scrollTop : pageYOffset
    var window_width=ieNOTopera? iecompattest().clientWidth+ieHoffset_extra : window.innerWidth+ieHoffset_extra
    var window_height=ieNOTopera? iecompattest().clientHeight : window.innerHeight
    
    if (document.all||document.getElementById){
    cross_obj.style.left=parseInt(dsocleft)+parseInt(window_width)-Hoffset+"px"
    cross_obj.style.top=dsoctop+parseInt(window_height)-Voffset+"px"
    }
    else if (document.layers){
    cross_obj.left=dsocleft+window_width-Hoffset
    cross_obj.top=dsoctop+window_height-Voffset
    }
    }
    
    function scrollwindow(){
    window.scrollBy(0,myspeed)
    }
    
    function initializeIT(){
    positionit()
    if (myspeed!=0){
    scrollwindow()
    }
    }
    
    if (document.all||document.getElementById||document.layers)
    setInterval("initializeIT()",20)
    
    </script>
    
    </body>
    </html>
    Is this possible?

    If so, what changes need to be made and where?

    Thanks

  2. #2
    Join Date
    Jul 2005
    Location
    Kuwait-I'm American
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    well, to save time, why dont you just put the code on pages that are scrollable. that way, there is no hassle, no fuss...
    //\\ //\\// || //\\//\\ //\\ ||_
    SOFTWARE

  3. #3
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by IanMarlowe
    well, to save time, why dont you just put the code on pages that are scrollable. that way, there is no hassle, no fuss...
    I could, but the pages are dynamic and the content always varies.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You must mean something like this:
    Code:
    <html>
    <head>
    <title>Variable Custom Scroll - Demo</title>
    </head>
    <body>
    
    <div id="staticbuttons" style="position:absolute;display:none;">
    <a href="javascript:" onmouseover="myspeed=-thespeed" onmouseout="myspeed=0"><img
    src="arrows_up.gif" border="0"></a><br>
    <a href="javascript:" onmouseover="myspeed=thespeed" onmouseout="myspeed=0"><img
    src="arrows_dn.gif" border="0"></a>
    </div>
    
    <script>
    
    //Page Scroller (aka custom scrollbar)- By Dynamic Drive
    //For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
    //This credit MUST stay intact for use
    
    var Hoffset=70 //Enter buttons' offset from right edge of window (adjust depending on images width)
    var Voffset=80 //Enter buttons' offset from bottom edge of window (adjust depending on images height)
    var thespeed=3 //Enter scroll speed in integer (Advised: 1-3)
    
    var ieNOTopera=document.all&&navigator.userAgent.indexOf("Opera")==-1
    var myspeed=0
    
    var ieHoffset_extra=document.all? 15 : 0
    var cross_obj=document.all? document.all.staticbuttons : document.getElementById? document.getElementById("staticbuttons") : document.staticbuttons
    
    function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }
    
    function positionit(){
    var dsocleft=document.all? iecompattest().scrollLeft : pageXOffset
    var dsoctop=document.all? iecompattest().scrollTop : pageYOffset
    var window_width=ieNOTopera? iecompattest().clientWidth+ieHoffset_extra : window.innerWidth+ieHoffset_extra
    var window_height=ieNOTopera? iecompattest().clientHeight : window.innerHeight
    
    if (document.all||document.getElementById){
    cross_obj.style.left=parseInt(dsocleft)+parseInt(window_width)-Hoffset+"px"
    cross_obj.style.top=dsoctop+parseInt(window_height)-Voffset+"px"
    }
    else if (document.layers){
    cross_obj.left=dsocleft+window_width-Hoffset
    cross_obj.top=dsoctop+window_height-Voffset
    }
    }
    
    function scrollwindow(){
    window.scrollBy(0,myspeed)
    }
    
    function initializeIT(){
    positionit()
    if (myspeed!=0){
    scrollwindow()
    }
    }
    
    function loadItUp(){
    var bodHeight=ieNOTopera? iecompattest().scrollHeight : iecompattest().offsetHeight
    var window_height=ieNOTopera? iecompattest().clientHeight : window.innerHeight
    if ((document.all||document.getElementById||document.layers)&&bodHeight>window_height){
    setInterval("initializeIT()",20)
    cross_obj.style.display='block'
    }
    }
    
    if ( typeof window.addEventListener != "undefined" )
        window.addEventListener( "load", loadItUp, false );
    else if ( typeof window.attachEvent != "undefined" ) {
        window.attachEvent( "onload", loadItUp );
    }
    else {
        if ( window.onload != null ) {
            var oldOnload = window.onload;
            window.onload = function ( e ) {
                oldOnload( e );
                loadItUp();
            };
        }
        else
            window.onload = loadItUp;
    }
    </script>
    Hi!
    <!--img src="some.jpg" width="1000" height="1000" border="0" alt="Test" title="Test"-->
    </body>
    </html>
    After loading this up to see what it does, try uncommenting the test image (near the bottom) and see what happens. I also tested it with a real image without giving the dimensions, worked that way too.

    Note: Mozilla may hang for a bit trying to load the nonexistent image, if so just refresh.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •