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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:48:05+00:00 2026-05-17T23:48:05+00:00

When double-clicking on a html page most browsers select the word you double-click on

  • 0

When double-clicking on a html page most browsers select the word you double-click on (or the paragraph you triple-click on). Is there a way to get rid of this behavior?

Note that I do not want to disable regular selection via single-click+dragging; i.e. jQuery UI’s $('body').disableSelection() and the document.onselectstart DOM event are not what I want.

  • 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-17T23:48:05+00:00Added an answer on May 17, 2026 at 11:48 pm

    I fear you can’t prevent the selection itself being “native behavior” of the browser, but you can clear the selection right after it’s made:

    <script type="text/javascript">
    document.ondblclick = function(evt) {
        if (window.getSelection)
            window.getSelection().removeAllRanges();
        else if (document.selection)
            document.selection.empty();
    }
    </script>
    

    Edit: to also prevent selecting whole paragraph by “triple click”, here is the required code:

    var _tripleClickTimer = 0;
    var _mouseDown = false;
    
    document.onmousedown = function() {
        _mouseDown = true;
    };
    
    document.onmouseup = function() {
        _mouseDown = false;
    };
    
    document.ondblclick = function DoubleClick(evt) {
        ClearSelection();
        window.clearTimeout(_tripleClickTimer);
    
        //handle triple click selecting whole paragraph
        document.onclick = function() {
            ClearSelection();
        };
    
        _tripleClickTimer = window.setTimeout(RemoveDocumentClick, 1000);
    };
    
    function RemoveDocumentClick() {
        if (!_mouseDown) {
            document.onclick = null; 
            return true;
        }
    
        _tripleClickTimer = window.setTimeout(RemoveDocumentClick, 1000);
        return false;
    }
    
    function ClearSelection() {
        if (window.getSelection)
            window.getSelection().removeAllRanges();
        else if (document.selection)
            document.selection.empty();
    }​
    

    Live test case.

    Should be cross browser, please report any browser where it’s not working.

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

Sidebar

Related Questions

Is there a way to set a mouse click or double-click handled in a
One way of doing it is double-clicking on each component and it will automatically
I have a html page, on this page there are some images, when the
part of my page requires some double-clicking, which has the undesirable effect that sometimes
While double-clicking the text of a QTreeView expands the children, a single-click does not.
In CFEclipse, I do a lot of double-clicking to select text. The standard behavior
I am willing to create div's dynamically on double clicking anywhere on the page.
You probably have noticed this behavior on thefreedictionary.com : on double-clicking a word, the
Double-clicking a TStaticText on a form copies the caption of that TStaticText to the
Symptoms In IIS 7 and Dot Net 2.0 Integrated app pool: double clicking to

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.