-
Notifications
You must be signed in to change notification settings - Fork 0
/
disable-text-select.html
70 lines (58 loc) · 1.74 KB
/
disable-text-select.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html>
<head>
<style>
.select_disabled{
user-select: none; /* supported by Chrome and Opera */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
}
/*p::selection {
background: transparent;
}
p::-moz-selection {
background: ;transparent
}
*/
/*.before_attr:before{
content:attr(disabled_text);
}*/
</style>
</head>
<body>
<div>
You can select and copy this Content.
</div>
<div class="select_disabled">
This text is disabled by setting the user-select property to text none
<!-- <div class="select_auto">
The user-select property for this text is set to auto
</div> -->
</div>
<p id="before_attr">This text will be disable after clicking the bottom below</p>
<button onClick="funct()">Click me</button>
<!--
<div> You can select and copy this content.</p>
<p> You can't select and copy this content.</p>
<p class="disabled_selection" disabled_text="These are the text created by after which yo can't select"></p>
<p class="disabled">I am disabled</p>
<p>I am enabled</p>
<div onmousedown='return false;'
onselectstart='return false;'
>will I be unselected?</div>
<div>Can I be selected</div>
<div class="mouseEvent1" onmousedown="return false">1. I can't be selected</div>
<div class="mouseEvent2" onselectStart="return false">2.I Can't be selected</div>
--></body>
<script>
function funt(){
var xyz= document.getElementById("before_attr");
xyz.style.WebkitUserSelect = "none"; // Chrome, Safari, Opera
xyz.style.MozUserSelect = "none"; // Firefox
xyz.style.msUserSelect = "none"; // IE 10+
xyz.style.userSelect = "none"; // Standard syntax
}
</script>
</html>