Results 1 to 5 of 5

Thread: Page Scroller (aka custom scroll bar)

  1. #1
    Join Date
    Dec 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Page Scroller (aka custom scroll bar)

    Hey guys love this script!!!!! i notices a bug though, it works perfectly in IE and Firefox however in Firefox (and only firefox as far as i can tell) if you click on one of the images (up arrow or down arrow) the javascript console pops up and gives this error:

    Error: cross_obj has no properties
    Source File: http://www.fiveforksmarket.com/pages/home.php
    Line: 82

    this site is curently under development and i cannot afford to stop. however the above link will be active however the line number could change so i am providing the code:

    LOOK FOR MY NOTE IN ALL CAPS TO INDICATE WHERE THERE ERROR LIES

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>

    <head>
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    <meta name="generator" content="Adobe GoLive">
    <title>Five Forks Market</title>
    <STYLE>
    body { scrollbar-base-color:#F9E915; }
    /*body { scrollbar-face-color: #f9e915; scrollbar-highlight-color: #ce670b; scrollbar-3dlight-color: #ce670b; scrollbar-shadow-color: #F9E915; scrollbar-darkshadow-color: #F9E915; scrollbar-track-color: #ce670b; scrollbar-arrow-color: #ce670b; }*/
    /*body { scrollbar-face-color: #ce670b; scrollbar-highlight-color: #F9E915; scrollbar-3dlight-color: #ce670b; scrollbar-shadow-color: #F9E915; scrollbar-darkshadow-color: #ce670b; scrollbar-track-color: #ce670b; scrollbar-arrow-color: #F9E915; }*/
    </STYLE>
    <SCRIPT LANGUAGE='JavaScript'>
    <!--
    if (top == window)
    location.href = '../index.php?page=about'
    -->
    </SCRIPT>

    </head>

    <body bgcolor="#ce670b" leftmargin="0" marginheight="0" marginwidth="0" topmargin="0">

    <div id="staticbuttons" style="position:absolute;">
    <a href="javascript:" onmouseover="myspeed=-thespeed" onmouseout="myspeed=0"><img
    src="arrows_up.gif" border="0"></a>
    <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=25 //Was 70Enter buttons' offset from right edge of window (adjust depending on images width)
    var Voffset=88 //Was 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
    }

    ***THE FOLLOWING LINE IS WHERE THE ERROR IS OCCURING***
    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>

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Hmm I don't get the error in Firefox, just that javascript console popping up, which is normal due to the link being "javascript:". A poor choice nevertheless. You can "fix" this by editing the links to:

    Code:
    <a href="javascript:" onmouseover="myspeed=-thespeed" onmouseout="myspeed=0" onClick="return false"><img
    src="arrows_up.gif" border="0"></a>
    <a href="javascript:" onmouseover="myspeed=thespeed" onmouseout="myspeed=0" onClick="return false"><img
    src="arrows_dn.gif" border="0"></a>
    Note the part in red.

  3. #3
    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

    I haven't followed this whole discussion but generally, if you are going to use:

    Code:
    href="javascript:" onclick="return false;"
    You may as well go the extra step of using:

    Code:
    href="javascript:void(0);"
    That way most non javascript enabled browsers won't get excited about it and you can even dispense with the onclick part.

    As I say, generally. I haven't studied this particular case in depth.
    - John
    ________________________

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

  4. #4
    Join Date
    Dec 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thanks For The Help

    I am going to recommend this site to everyone!

  5. #5
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Your solution works just as well John

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
  •