Stop Chrome from highlighting the canvas section

One interesting feature of our whiteboard application is that Chrome users have the ability to highlight the entire canvas by dragging their mouse in a specific manner:

Do you have any suggestions on how we can prevent this behavior? Thank you!

Answer ā„–1

Using this CSS code on the body element has worked well for me in Chrome:

-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;

Some have mentioned that Opera and IE do not fully support these properties, and recommend using the unselectable attribute on specific elements instead, like this:

<body unselectable="on">

I do not have access to Opera or IE to verify this, but you can refer to the following posts for more information:

How to disable text selection highlighting using CSS?

Is there a way to make text unselectable on an HTML page?

Answer ā„–2

To ensure that text selection is disabled, remember to apply the following CSS specifically to the CANVAS element. If this CSS is mistakenly applied to the body, it will also disable text selection for the entire page.

  canvas{
     -webkit-touch-callout: none;
     -webkit-user-select: none;
     -khtml-user-select: none;
     -moz-user-select: none;
     -ms-user-select: none;
     -o-user-select: none;
     user-select: none;
  }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Changing CSS styles dynamically using PHP

After stumbling upon a customizer live preview layout picker, I have finally found what I've been searching for ā€“ a live layout changer for WordPress. This solution works like a charm, but I'm wondering if there is a more efficient way to write ...

Determine the number of visible li elements using jQuery

Currently, I am utilizing a jQuery script to count the number of li elements in my HTML code. Here is an example of the setup: HTML: <ul class="relatedelements"> <li style="display:none;" class="1">anything</li> <li style="disp ...

Encountering a NullPointerException while trying to load a resource from a directory that is not within

I'm working with JavaFX and trying to incorporate a CSS file into my scene. scene.getStyleSheets().add(Main.class.getResource("res/application.css").toExternalForm(); An NPE is being thrown. I suspect it's because the css file isn't locate ...

The presence of a white block as the background on a webpage in Ubuntu

Currently working on a website in Ubuntu 14.10. Encountering an issue with Chrome not rendering the background correctly. The footer displays fine, covering the entire width, but the content div background remains white. Check out the image for visual re ...

Can you suggest a more effective method for changing the color of buttons?

While the title provides some context, allow me to elaborate further. I've been working on a website for quite some time now. Each section of the website features 3 buttons, each highlighted in a unique color. My question is, is there a more streamlin ...

Tips for displaying two dynamic variables that are interdependent

For instance: Controller: AllBooks[{ book1:{ hardcover{price:25.99},e-book{price:1.99} } }, book2:{ hardcover{price:60.00},e-book{price:2.99} }]; $scope.bookchoice = function(selectedBook) { $rootScope.choice = selectedBook;} $scope.booktype = functio ...

Troubleshooting custom fonts not displaying on a .NET website: Importing fonts for web use

https://i.stack.imgur.com/uWSsY.pngI am well-versed in HTML, but my knowledge of VB.NET is limited. In standard CSS, including a font like the one below would typically work, but I have encountered issues when attempting to do so in .NET. @font-face { f ...

The functionality of the Bootstrap navbar-fixed-top seems to be malfunctioning

I am currently working on creating a page layout with a fixed navigation bar positioned at the top. I am aiming for a design similar to the one showcased here. Upon examining the example linked above, it appears that the content of the page begins below t ...

Challenges faced when utilizing AJAX within a PHP loop

I am currently using a PHP WHILE loop to showcase multiple products, each with its own unique id#. These products can be rated using a PHP AJAX JQUERY-based system. However, after a user rates a product and the AJAX response returns the value, it is curren ...

Binding data to an MVC grid component

I am working with asp.net mvc3.0 razor framework and using an html Table to populate data from ViewBag based on the selected option in a dropdownlist. public ActionResult Index(GetFileName fn) { .... ViewBag.Grid1Data = dt; return View(); } Initially, th ...

Creating a magical transformation for the bootstrap carousel

Trying to create a bootstrap wizard with a carousel and disable auto-scrolling by setting bs-interval to "false" without success. Here is my code: <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" ...

The jQuery.addClass() function seems to be malfunctioning

I'm encountering an issue with the addClass() method. For some reason, it's not functioning properly in this scenario: https://jsfiddle.net/0g1Lvk2j/20/ If you scroll to the end and close the last box by clicking on the orange box, the orange b ...

Arranging Bootstrap dropdown and buttons on a single line

Check out my code snippet here: http://jsfiddle.net/52VtD/7462/ I'm facing an issue where I want to align my dropdown and buttons on the same line, but the dropdown being a div, it stays on the line below. How can I ensure they are on the same line? ...

Dynamic image gallery with a flexible layout and interactive scrollbar using Flexbox

I'm looking to incorporate a scrolling image gallery into a flexbox layout so that as the browser page size changes, the gallery will scale according to the flex-grow index. My goal is to ensure all images remain accessible via a scrollbar without usi ...

increasing the size of the input thumb compared to the others

Hello fellow React developers, I'm currently learning by coding and I have a question about a slider. I'm trying to make the thumb of the slider bigger, but when I increase its size it doesn't fully display within the input area (as you can ...

How to access form elements within a submit function without specifically defining the form name

I have a form that I am submitting using a submit function. However, instead of using document id for submission variable, I am utilizing classes. $(".modalform").submit(function(event) { /* prevent form from submitting normally */ event.preventDefa ...

The navigator's userAgent property is used to match specific handset identifications

When identifying users on specific devices, I use navigator.userAgent.match to detect certain phones. However, with Android devices, there are various tablets, phones, and set-top boxes to consider. So, my code snippet looks like this: if(navigator.userAg ...

What is the method for adding a tag within a specific div ID in ExtJS?

I am looking to insert a new tag within existing tags using extjs, based on the div id 'task123', and also trigger an alert message accordingly. Below is the HTML code snippet: <div id="task123"> <div class="msg" id="sample"> ...

Preventing text from wrapping in a TypeScript-generated form: Tips and tricks

Iā€™m currently working on a ReactJS project and my objective is simple: I want all three <FormItem> components to be displayed in a single line without wrapping. However, I am facing the following output: https://i.stack.imgur.com/mxiIE.png Within ...

Hover effect triggered upon mouse exit

As I delve into learning the basics of HTML and CSS, I came across the :hover property in CSS. This unique feature allows for a specific action to occur when the cursor hovers over an element, based on the code provided. Additionally, I discovered the tran ...