2012-03-08 9 views
5

मेरे पृष्ठ के भाग के लिए कुछ डबल-क्लिक की आवश्यकता है, जिसमें अवांछनीय प्रभाव पड़ता है जिसे कभी-कभी उपयोगकर्ता अनजाने में पृष्ठ पर कुछ टेक्स्ट को हाइलाइट करता है।एचटीएमएल टेक्स्ट को हाइलाइट किया जा रहा है

यह वास्तव में वास्तव में अस्पष्ट है, लेकिन पाठ के बजाय छवियों का उपयोग करने के अलावा, यह हो रहा है रोकने के लिए एक साफ तरीका है?

धन्यवाद

उत्तर

11

यहाँ सीएसएस पाठ चयन को अक्षम करता है। How to disable text selection highlighting using CSS?

-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; 
+1

मेरे लिए काफी अच्छा है! धन्यवाद :) – CompanyDroneFromSector7G

+2

आपने क्यों जोड़ा-webkit-touch-callout: none ;? –

2

रूप @arunes सुझाव दिया, आप सबसे ब्राउज़रों के लिए सीएसएस के साथ ऐसा कर सकते हैं। हालांकि मैंने पढ़ा है कि यह आईई 6-8 (कम से कम) के साथ काम नहीं करता है। तो उस के लिए, आप की तरह कुछ जरूरत हो सकती है:

document.getElementById("divDoubleClick").onselectstart = function() { return false; }; 
2

यह मेरे लिए काम करता

के रूप में सुझाव

body, div 
{ 
    -webkit-touch-callout: none; 
    -webkit-user-select: none; 
    -khtml-user-select: none; 
    -moz-user-select: -moz-none; 
    -ms-user-select: none; 
    -o-user-select: none; 
    user-select: none; 
} 

में सीएसएस शैलियों डाल भी इन जोड़ने के प्रपत्र फ़ील्ड्स के भीतर चयन अनुमति देने के लिए

input, textarea, .userselecton 
{ 
    -webkit-touch-callout: text; 
    -webkit-user-select: text; 
    -khtml-user-select: text; 
    -moz-user-select: text; 
    -ms-user-select: text; 
    -o-user-select: text; 
    user-select: text; 
} 

नोट करें -मोज़-कोई भी आवश्यक नहीं है या इनपुट के लिए पुन: सक्षम नहीं है।

IE के लिए

मैं

<script type="text/javascript"> 
    window.addEvent("domready", function() 
    { 
     document.addEvent("selectstart", function(e) 
     { 
      if ((e.target.tagName == "INPUT") || 
      (e.target.tagName == "TEXTAREA") || 
       (e.target.hasClass("userselecton"))) 
      { 
       return true; 
      } 
      return false; 
     }); 
    }); 
</script> 

यह न केवल पृष्ठभूमि पाठ के चयन से बचाता है लेकिन inputfields पर चयन की अनुमति देता है जोड़ सकते हैं और और तत्व आप पर userseleton वर्ग डाल दिया।

+0

धन्यवाद उपयोगी जानकारी! – CompanyDroneFromSector7G

संबंधित मुद्दे