Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javascript/DHTML help needed

Options
  • 18-01-2001 7:43pm
    #1
    Registered Users Posts: 12,309 ✭✭✭✭


    Hi guys... I need ye'r help..!

    I wonder is it possible to create a script in JavaScript/DHTML which will allow me to have a button - graphical or form - doesn't matter, - which makes your browser scroll down, say 300 pixels exactly... ?

    Anyone any thoughts?

    I'd do it with a simple <a name> and <a href> combination in HTML but unfortunately this isn't working quite as planned...


Comments

  • Registered Users Posts: 861 ✭✭✭Slosh


    *Works fine in IE5, Im sure 4 would be okay too... Easy enough to convert to Javascript..

    <script language="VBScript">

    sub ScrollWindow(iScrollValue)

    window.scrollBy 0,iScrollValue

    end sub

    </script>

    <!-- Page contents -->

    <input type=button onclick="ScrollWindow(300)" name=btnScroll>


  • Registered Users Posts: 2,660 ✭✭✭Baz_


    well thats quite handy slosh I might use that one myself sometime. Oh and here is my attempt at a conversion, although you're probably done by now, and remember its just an attempt and it hasn't been tested.
    &lt;script language="Javascript"&gt;
    
    function ScrollWindow(iScrollValue)
    {
        window.scrollBy 0,iScrollValue
    }
    
    &lt;/script&gt;
    
    &lt;!-- Page contents --&gt;
    
    &lt;input type=button onclick="ScrollWindow(300)" name=btnScroll&gt;
    
    

    not sure how that works in java of course, I imagine you will have to alter the window.scrollby function/property whatever it is.

    neway ta slosh


  • Registered Users Posts: 12,309 ✭✭✭✭Bard


    Thanks Slosh... I'll have to try it out tomorrow (been out sick from work).

    Cheers,



    bard2.gif


  • Registered Users Posts: 1,481 ✭✭✭satchmo


    scrollBy(x,y) will scroll the window relative to where it is at the moment, but you can also use scrollTo(x,y) which will scroll the window absolutely. eg self.scrollTo(0,100) would scroll to 100 pixels down, no matter where you are.


Advertisement