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

  • SEARCH
  • Home
  • 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 828629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:45:14+00:00 2026-05-15T03:45:14+00:00

How to distinguish between blank areas and non-blank areas in a webpage with JavaScript?

  • 0

How to distinguish between blank areas and non-blank areas in a webpage with JavaScript? Blank areas including:

  • areas that are not occupied by DOM elements.
  • margins, borders and paddings of DOM elements.

EDIT:
As response to the first comment: I am working on a web-based ebook reader. Cursor is set to {cursor:move} for blank areas so that the user can drag and scroll the webpage.

  • 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-15T03:45:15+00:00Added an answer on May 15, 2026 at 3:45 am

    You could recursively go through each element and attach onmouseover and onmouseout events (where the former enables the text cursor and the latter enables the move cursor) on each which has text in it, e.g:

    function attachEvents(e) {
        if (n.nodeType == 3) { // Node.TEXT_NODE
            // A text node - add the parent as an element to select text in
            e.parentNode.onmouseover = elmMouseOver /* define your own event fns */
            e.parentNode.onmouseout = elmMouseOut
        }
        else if (n.nodeType == 1) { // Node.ELEMENT_NODE
            for (var m=e.firstChild; m != null; m = m.nextSibling) {
                attachEvents(m)
            }
        }
    }
    

    The best way I can think of to make sure it’s actually “text” which is moused over and not a blank area is to use e.g. <div><span>content</span></div> and put the mouseover/mouseout events in the <span> so that blank areas don’t trigger events. This is what I’d recommend doing if you can, as things can get very complicated if you use block elements with padding from my experience. For example:

    | The quick brown fox jumps |
    | over the lazy dog         | <- onmouseover/out of SPANs will ignore the space 
                                     after "dog" while DIVs won't and you won't need 
                                     to calculate padding/margins/positions which 
                                     makes it faster and more simple to implement
    

    If you have to use block DIVs: You could use something like jQuery’s jSizes plugin to get margins/padding in pixels or this (for a way to get the inherited CSS values and parse yourself by removing the px part from the end etc)

    After that, you could figure out the position using position() in jQuery. I personally don’t use jQuery for my stuff, but I use those specific “find positions” functions and found them to be one of the best I think in large part because of number of users testing them.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a javascript regex that can distinguish between PHP tags in HTML tags
I can not distinguish the difference between aggregating and holding. What does it mean
I want to distinguish between various execution paths in linux kernel so that I
Any portable code that uses bitfields seems to distinguish between little- and big-endian platforms.
How can I get C# to distinguish between ambiguous class types without having to
How, in the simplest possible way, distinguish between Windows XP and Windows Vista, using
The question, in brief: In MVC, how do you distinguish between a checkbox click
How do you distinguish between a patch and an upgrade? Where do you draw
Can I distinguish between compiled application from VS2008 Professional and Express?
Does iPhone OS distinguish between foreground and background threads?

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.