Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Javascript/DHTML help needed

  • 18-01-2001 07:43PM
    #1
    Registered Users, Registered Users 2 Posts: 12,311 ✭✭✭✭


    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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 12,311 ✭✭✭✭Bard


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

    Cheers,



    bard2.gif


  • Registered Users, Registered Users 2 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