Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7190529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:32:07+00:00 2026-05-28T19:32:07+00:00

I have the following html page. Why does alert not working when I scroll

  • 0

I have the following html page. Why does alert not working when I scroll the mouse?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html lang="en">
     <head>
     <script src="http://code.jquery.com/jquery-latest.js"></script>


      <script>
      $(window).scroll(function(){
                alert("scrolling");
            });
      </script>
     </head>
     <body>

     </body>
    </html>

EDIT: It works when page has the scroll bar on the right side and when scroll moves the page down. But I want it to work on empty page, for instance.

EDIT2: I have changed document.body to window but have the same problem.

EDIT3: So, i have come to result that I want to catch mouse wheel event

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:32:08+00:00Added an answer on May 28, 2026 at 7:32 pm

    It’s not the body but the window.
    However I would put it after the document is ready.
    Here’s a working code:

        $(document).ready( function ()
        {
            console.log('ready');
            $(window).scroll( function ()
            {
                console.log('scroll');
            });
        });
    

    In answer to your edit 3
    To catch the mouse wheel event use the jquery mousewheel_plugin see this example

    So your code would be

    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript" src="jQuery_mousewheel_plugin.js"></script>
    <script>
    
        var intOverallDelta = 0;
    
        $(document).ready( function ()
        {
            console.log('ready');
            $(document.body).mousewheel(function(objEvent, intDelta)
            {
                if (intDelta > 0)
                {
                    intOverallDelta++;
                    console.log('up - (' + intOverallDelta + ')');
                }
                else if (intDelta < 0)
                {
                    intOverallDelta--;
                    console.log('down - (' +  intOverallDelta + ')');
                }
            });
        });
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Javascript code add_num = { f: function(html, num) { alert(this.page);
I have the following webform: <%@ Page Language=C# AutoEventWireup=true CodeBehind=Default.aspx.cs Inherits=TestWebApp.Default %> <!DOCTYPE html
I have the following HTML Code <%@ Page Language=C# %> <html> <head> <title></title> </head>
in my html page, I have the following: <div id=rub> Select at least one
Let's say I have a web page ( /index.html ) that contains the following
What changes do I have to make to the following simple HTML page to
Writing a code that does the following: Adds a mouse listener to a web-page
In the following HTML page, I have a div, which contains two spans (
I have the following HTML on my web page: <input id=htmlEdit type=checkbox/> Once the
I have embedded the signed applet in following html page, <input type=hidden name=xmldata id=xmldata

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.