dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: javascript scrollbar call

Hybrid View

  1. #1
    Join Date
    Apr 2011
    Posts
    68

    javascript scrollbar call

    hello javascript Pros!

    i have a problem in javascript..

    i want to get the value in scrollbar..

    example:

    if im doing scrolling it wont increment the variable but if i stop, it will do incrementation...

    so how can you do that..

    i can do the opposite of it.. which is kinda not the output the way i wanted.

  2. #2
    Join Date
    Apr 2011
    Posts
    68
    function a(){
    window.onscroll = scroll3;
    var count3=0;


    function scroll3(){

    count3++;
    alert("every time i move why do i always alert?");
    }
    return scroll3
    }
    return a();

    this is the code>.. so how can i make my scroll wont alert everytime it move?? i want to alert once im done on scrolling.. can you please help me?

  3. #3
    Join Date
    Mar 2009
    Location
    Wherever i lay my hat
    Posts
    180
    Something like this? It creates a timeout everytime you scroll the page and erases the old timeout. If you scroll again within 300ms, nothing happens, but if you don't, the callback function gets called and increments the value.

    HTML Code:
    <!DOCTYPE html>
    <html>
        <head>
            <style>
                #content {
                    background-color    : #ff0;
                    height              : 2000px;
                    margin              : auto;
                    width               : 640px;
                    }
                #counter {
                    background-color    : #090;
                    padding             : 20px;
                    position            : fixed;
                    }
                </style>
            <script>
                var count = 0,
                    timeOut;
                window.onscroll = function() {
                    clearTimeout( timeOut );
                    timeOut = setTimeout( function() {
                        document.getElementById( "counter" ).childNodes[ 0 ].nodeValue = count++;
                        }, 300 );
                    }
                </script>
            <title>Scrollstop</title>
            </head>
        <body>
            <span id = "counter">0</span>
            <div id = "content"></div>
            </body>
        </html>

  4. #4
    Join Date
    Apr 2011
    Posts
    68
    wow thanks! this is exactly the output that i want to achieve.. XD i cant believe that it's possible thank you very much

  5. #5
    Join Date
    Mar 2009
    Location
    Wherever i lay my hat
    Posts
    180
    Always happy to help May i ask where do you use such functionality?

    Also, mark this as Resolved.
    Last edited by haulin; 02-05-2013 at 09:47 AM.

  6. #6
    Join Date
    Apr 2011
    Posts
    68
    @haulin, i want to create a custom rotating ads.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles