The function of shielding the text to be selected automatically when the mouse is right-clicked

if you right-click on an element, it will be selected if there is text near the text.
now I want to remove this default function
. There are two
1 css user-select:none;
2 js window.getSelection (). RemoveAllRanges ();
methods that have been tried. Both methods have a problem: they will clear out the text that was manually selected before

.

Boss, thank you very much for giving me some ideas that have done similar functions.

Mar.22,2021

even if you don't write anything, by default. The user's right click will also clear the previously manually selected text


document.addEventListener('mousedown', (event) => {
      // 
      if (event.button === 2) {
        // 
        if (window.getSelection().isCollapsed) {
          // 
          document.body.style.userSelect = 'none';

          // 
          setTimeout(() => {
            document.body.style.userSelect = 'auto';
          }, 0);
        }
      }
    });
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bf27-2bb1f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bf27-2bb1f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?