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.
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?
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>
wow thanks! this is exactly the output that i want to achieve.. XD i cant believe that it's possible thank you very much
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 08:47 AM .
@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
Forum Rules
Bookmarks