user-selectअधिकांश आधुनिक ब्राउज़रों में काम करने का स्वामित्व भिन्नताएँ होंगी:
*.unselectable {
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
IE <10 और ओपेरा के लिए, आपको unselectableउस तत्व की विशेषता का उपयोग करने की आवश्यकता होगी जिसे आप अचूक होने की इच्छा रखते हैं। आप इसे HTML में एक विशेषता का उपयोग करके सेट कर सकते हैं:
<div id="foo" unselectable="on" class="unselectable">...</div>
अफसोस की बात है कि यह संपत्ति विरासत में नहीं मिली है, जिसका अर्थ है कि आपको प्रत्येक तत्व के प्रारंभ टैग में एक विशेषता डालनी होगी <div>। यदि यह एक समस्या है, तो आप इसके बदले जावास्क्रिप्ट का उपयोग किसी तत्व के वंशजों के लिए कर सकते हैं:
function makeUnselectable(node) {
if (node.nodeType == 1) {
node.setAttribute("unselectable", "on");
}
var child = node.firstChild;
while (child) {
makeUnselectable(child);
child = child.nextSibling;
}
}
makeUnselectable(document.getElementById("foo"));