The below code is working fine for Firefox browser. But, not chrome. What is the issue in below code ?
window.onload = function()
{
document.body.onscroll = Test.callFn;
}
var Test = new function()
{
this.callFn = function()
{
console.log("Calling this function");
}
}
Thanks
This onscroll attribute works when an element scrollbar is being scrolled. To create a scrollbar in an element, use the CSS overflow property. Supported Tags: It supports all HTML elements. Attribute: This attribute is supported by all HTML elements and the attribute works when script triggered. science.
The HTML DOM onscroll event occurs when a scrollbar is used. CSS overflow is used to create a scrollbar. HTML stands for Hyper Text Markup Language. It is used to design web pages using markup language. HTML is the combination of Hypertext and Markup language.
Syntax: 1 In HTML: <element onscroll="myScript"> 2 In JavaScript: object.onscroll = function () {myScript}; 3 In JavaScript, using the addEventListener () method: object.addEventListener ("scroll", myScript);
Toggle between class names on different scroll positions - When the user scrolls down 50 pixels from the top of the page, the class name "test" will be added to an element (and removed when scrolled up again). Slide in an element when the user has scrolled down 350 pixels from the top of the page (add the slideUp class):
This might also happen when the height of html
and body
tags is set to 100% and the scroll event does not fire for window nor document. To check which element is scrolled I slightly modified Aaron Mason's snippet which wasn't working for me either:
document.querySelectorAll('*').forEach(function(elem) {
elem.addEventListener('scroll', function() {
console.log(this);
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With