|
| |||||||||
| Tags: boolean flag, detect, internet explorer, javascript, netscape, pixel value, scrolling |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| ||||
| ||||
| How to detect when scrolling occurs in JavaScript?
Hi folks, I have done many different events in JavaScript. I am not able to know how to detect when scrolling occurs in JavaScript? And also please tell me how to use that as a JavaScript event. If you provide the sample of the code that would be much useful for me. So its a kind request to give some coding related to the topic. Hope that you guys will help me soon..!! ![]()
__________________ |===================| |YAY if that made sense...| |===================| |
|
#2
| ||||
| ||||
| Re: How to detect when scrolling occurs in JavaScript?
I think that you should set a boolean flag, whose move should be stopped after moving the screen programmatically. By doing this the scroll-listener would first check against that flag and then do the respective actions. Otherwise instead of inline on the body command, you can also add the event called onscroll during the document.onReady event. Doing something like I did might help you. Check this script : Code: <script language="javascript">
document.observe('user:scrolling', function() { alert('Wow!'); });
</script>
...
<body onscroll="document.fire('user:scrolling')">
__________________ 3.2 (northwood) 2gig ramATI AIW X800xt 256mb Gigabyte GA-8knxp 875p Chipset Optiwrite 8X DVD Burner Win XP PRO Sp2 (Works Perfectly) 2 SATA Raptor 74gig Raid 0 2 7200 IDE 320gig HD |
|
#3
| |||
| |||
| Re: How to detect when scrolling occurs in JavaScript?
I know the code for the JavaScript that detects an an element after the scrolling takes place into view. For this coding I have used the Yahoo User Interface. Hope that you will get some useful thing from this coding. Code: var Event = YAHOO.util.Event;
var Dom = YAHOO.util.Dom;
Event.on(window, 'load', function() {
var y = Dom.getY('ft');
Event.on(window, 'scroll', function() {
var top = (document.documentElement.scrollTop ?
document.documentElement.scrollTop :
document.body.scrollTop);
var vpH = Dom.getViewportHeight();
var coverage = parseInt(vpH + top);
if ( coverage >= y ) {
console.log('Now in view!!!');
}
});
}); |
|
#4
| ||||
| ||||
| Re: How to detect when scrolling occurs in JavaScript?
You need to do the scrolling when you are having a large image that had to be scrolled both vertically and horizontally to view it properly. For doing this you will have to use the position scrolled to before the image map unloaded. And after this you will have to insert a cookie on the viewer's machine to store scrollbar positions. By doing this when you hit back, the cookie will automatically scrolled to the last position they were at in the image map (scrollTo()). Hope that you will get some hint from this explanation. |
|
#5
| ||||
| ||||
| Re: How to detect when scrolling occurs in JavaScript?
You should know that the browsers store the current position of both the vertical and horizontal scrollbars in JavaScript properties. You can determine where the viewer have scrolled on your page by accessing the properties of browser to retrieve the pixel values. The value of the vertical scrollbar in a property is stored in Internet Explorer. This property is called as "document.body.scrollTop". Also the property called "document.body.scrollLeft" stores the value of the horizontal scrollbar in Internet Explorer.
__________________ The FIFA Manager 2009 PC Game |
|
#6
| ||||
| ||||
| Re: How to detect when scrolling occurs in JavaScript?
I am giving you some steps that are necessary for the scrolling event in JavaScript :
|
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to detect when scrolling occurs in JavaScript?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error occurs while connecting USB to the nokia C6-01 | Siketan | Portable Devices | 6 | 07-06-2011 05:49 PM |
| Help me to set up Windows Mail ( error occurs) | leadye | Technology & Internet | 2 | 15-09-2009 09:33 AM |
| Problem to detect the javascript opener. | garfield1 | Software Development | 3 | 29-06-2009 11:58 PM |
| Vertical scrolling...jumps rather than smooth scrolling - Excel 20 | Miller Man | Vista Hardware Devices | 4 | 24-04-2009 08:36 AM |
| Detect IE 7 Protected mode using javascript | John | Vista Help | 0 | 28-09-2008 05:03 PM |