I am trying to find a way to be able to restrict text selection within the entire PhoneGap application. Anyone know a way to do this?
            Asked
            
        
        
            Active
            
        
            Viewed 3,705 times
        
    4
            
            
        - 
                    Seems to be a duplicate of: http://stackoverflow.com/questions/5995210/disabling-user-selection-in-uiwebview – poiuytrez Mar 11 '13 at 15:28
3 Answers
6
            
            
        this will work for you:-
<style type="text/css">
   *:not(input):not(textarea) {
   -webkit-user-select: none; /* disable selection/Copy of UIWebView */
   -webkit-touch-callout: none; /* disable the IOS popup when long-press on a link */
  }     
</style>
Using java script:-
 document.documentElement.style.webkitTouchCallout = "none";
 document.documentElement.style.webkitUserSelect = "none";
 
    
    
        Suhas Gosavi
        
- 2,170
- 19
- 40
5
            
            
        html {
-webkit-user-select: none;
}
this little ingredient in your css code will do the magic!
 
    
    
        thms
        
- 97
- 1
- 10
- 
                    I used this response along with @Suhas -webkit-touch-callout and it works great... vote for both... – agfa555 May 21 '15 at 10:58
2
            
            
        In iOS 9 there is a bug which makes the -webkit-user-select: none; not work. There is a plugin which fixes this
https://github.com/EddyVerbruggen/cordova-plugin-ios-longpress-fix
Thanks to Frederik Wessberg https://stackoverflow.com/a/32737049/741850
 
    
    
        Community
        
- 1
- 1
 
    
    
        Automatico
        
- 12,420
- 9
- 82
- 110
- 
                    Thanks this solved it. How ever since the plugin does not do that much you might wanna consider just copying the implementation. – Ramon Gebben Oct 14 '15 at 08:42
