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 8090953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:53:56+00:00 2026-06-05T19:53:56+00:00

We have a bookmarklet, and the user clicks a button and an inspect like

  • 0

We have a bookmarklet, and the user clicks a button and an inspect like highligther needs to kick in. We want to this to be cross browser.

For this we need to detect the DOM element during the mouse move, and once we have this element we need to highlight with CSS.

We have problems detecting the DOM element by mouse move, can you guide us how this is done?

Once we have this DOM element, on user click we need to extract XPath.

  • 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-06-05T19:53:57+00:00Added an answer on June 5, 2026 at 7:53 pm

    You can hook mousemove on document or document.body, then use the target property of the event object to find out the topmost element the mouse is over. Then applying CSS to it is probably most easily done by adding a class to it.

    It’s tempting to think the :hover psuedo-class could do it without JavaScript, but I’m struggling to see how to apply it only to the "deepest" hovered element (for instance, in <p>x<em>y</em>z</p>, only to the em and not the p).

    Here’s an example using JavaScript (not :hover):

    let prev = null;
    
    document.body.addEventListener(
        "mouseover",
        (event) => {
            if (event.target === document.body || (prev && prev === event.target)) {
                return;
            }
            if (prev) {
                prev.classList.remove("highlight");
                prev = null;
            }
            if (event.target) {
                prev = event.target;
                prev.classList.add("highlight");
            }
        },
        false
    );
    .highlight {
        background-color: yellow;
    }
    <p>I'm a paragraph, with <strong>some strong text</strong>, and some <em>emphasized text</em>.</p>
    <p>I'm another paragraph.</p>
    <div>Here's a div</div>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript like this, used i a bookmarklet: window.location=URL document.getElementById('username-id').value = 'User'
I have come across Evernote's bookmarklet and was wondering how this worked. You can
I have this script loaded on a page: (function() { window.alert('bookmarklet started'); function AjaxSuccess(data,
I have this bookmarklet, i.e. it does not start with 'http:' but with 'javascript:'.
I have a bookmarklet that needs to open a new window/tab. In order to
I have a JavaScript bookmarklet that I'd like fans of a certain page to
I have this bookmarklet javascript:%28function%28%29%7Bvar%20a%3Ddocument.createElement%28%22script%22%29%3Ba.type%3D%22text%2Fjavascript%22%3Ba.src%3D%22http://www.foo.com/bar.js.php%3F%22%2BMath.random%28%29%3Bdocument.getElementsByTagName%28%22head%22%29%5B0%5D.appendChild%28a%29%7D%29%28%29%3B On my home page I will create a button
I have a Javascript bookmarklet that, when clicked on, redirects the user to a
I would like a javascript bookmarklet that will click on the facebook like button
Let's say I have a page where a user has an option to like

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.