How to exclude parts of text when copying

I'm trying to make some text not copyable, my goal is not to prevent people from copying text from my site, but even more to simplify its use. I have a list of files with file size, but I only want to copy the file names, not the file size.

So far I tried several different methods, but did not work, I managed to get the text without selection using a CSS user, but I can still copy the file size when two or more lines are selected.

I just tried using a button to prevent copying in which the ether did not work, any ideas?

<a href="http://10.10.10.1/links/file.doc"file.doc</a>
 <button type="button" disabled="disabled" id="filesize">6 MB</button><br \>

The target browser is Safari on Mac, so the experimental CSS3 or HTML5 commands that work with the latest Safari are great.

(Thanks mvds for the proposed title and one solution)

+3
source share
3 answers

It's terrible to crack a warning: create 2 versions of the text, one with one and without dimensions, otherwise identical, and put them in overlapping divs, with the version without sizes with a higher z-index.

The best solution, maybe not a cross browser, is to add

<input type="text" value="(6 MB)" style="border:0; ...">

I suggest renaming the question “how to exclude parts of the text when copying”, because since it’s standing now, it looks like you are looking for an average hopeless copy protection scheme, while the question is quite interesting.

+2
source

- ::before ::after css content:.

HTML:

<a href="http://10.10.10.1/links/file.doc">file.doc</a>  
<button type="button" disabled="disabled" id="filesize"><i></i></button>

CSS

button i:before {
 content: '6 MB';
}

: : .

: CSS, . content: css.

+2

span ( ) unselectable, :

<a href="http://10.10.10.1/links/file.doc">file.doc</a>
<span unselectable="on">6 MB</span>

, , :)

, , - CSS, :

.unselectable { 
  user-select: none; 
  -moz-user-select: none; 
  -khtml-user-select: none; 
}

, :

<a href="http://10.10.10.1/links/file.doc">file.doc</a>
<span class="unselectable" unselectable="on">6 MB</span>
0

Source: https://habr.com/ru/post/1755103/


All Articles