admin管理员组文章数量:1305066
In my below code a function to scroll DIV for every set of intervals where when I try to scroll up due to interval refresh scroll bar again ing down.
My code:
var int = self.setInterval("f2()", 1000);
function f2() {
var objDiv = document.getElementById("messages2");
objDiv.scrollTop = objDiv.scrollHeight;
}
Now, by using onscroll
property for DIV is there anyway to stop scrolling down when holding scroll bar with mouse?
Something like
var int = self.setInterval("f2()", 1000);
function f2() {
var objDiv = document.getElementById("messages2");
// if(objDiv.onscroll) i.e. when the particular DIV's scroll bar is on hold by cursor.
{
return false;
}
else
{
objDiv.scrollTop = objDiv.scrollHeight;
}
}
If the above kind of function can be implemented anybody please correct its syntax. I am a newbie to JavaScript.
Thanks in advance..!
In my below code a function to scroll DIV for every set of intervals where when I try to scroll up due to interval refresh scroll bar again ing down.
My code:
var int = self.setInterval("f2()", 1000);
function f2() {
var objDiv = document.getElementById("messages2");
objDiv.scrollTop = objDiv.scrollHeight;
}
Now, by using onscroll
property for DIV is there anyway to stop scrolling down when holding scroll bar with mouse?
Something like
var int = self.setInterval("f2()", 1000);
function f2() {
var objDiv = document.getElementById("messages2");
// if(objDiv.onscroll) i.e. when the particular DIV's scroll bar is on hold by cursor.
{
return false;
}
else
{
objDiv.scrollTop = objDiv.scrollHeight;
}
}
If the above kind of function can be implemented anybody please correct its syntax. I am a newbie to JavaScript.
Thanks in advance..!
Share Improve this question edited Dec 27, 2011 at 18:16 Michael A 9,93022 gold badges72 silver badges117 bronze badges asked Dec 27, 2011 at 18:10 Mad coder.Mad coder. 2,1759 gold badges38 silver badges53 bronze badges1 Answer
Reset to default 6I’m not sure what you are asking here, but window
has a scroll event that you can listen to, and so does any other element that has overflow: auto|scroll
set using CSS.
You can’t prevent the default scrolling behavior, but you can use the scrollTo()
method or the scrollTop
property if you want to do something annoying like:
window.onscroll = function() {
window.scrollTo(0,0);
};
Here is a nice pat table of the scroll event: http://www.quirksmode/dom/events/scroll.html
scrollTo()
docs: https://developer.mozilla/en/Window.scrollTo
本文标签: scrollbarIs there any way to control scroll bar using JavaScriptStack Overflow
版权声明:本文标题:scrollbar - Is there any way to control scroll bar using JavaScript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741795220a2397896.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论