Disabling text selection in PhoneGap

后端 未结 9 696
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 14:14

Is it possible to disable text selection to make a PhoneGap app more similar to normal native app?

Something like this:



        
相关标签:
9条回答
  • 2020-12-02 14:54

    Add this and enjoy. Works on iOS as well.

    <style type="text/css">
    *:not(input,textarea) {
        -webkit-touch-callout: none;
        -webkit-user-select: none; /* Disable selection/Copy of UIWebView */
    }
    </style>
    
    0 讨论(0)
  • 2020-12-02 14:59

    I used below code and its working fine on Android and iOS devices as well as on emulator/simulator:

     * {
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        }
    
       input, textarea {
        -webkit-user-select: auto !important;
        -khtml-user-select: auto !important;
        -moz-user-select: auto !important;
        -ms-user-select: auto !important;
        user-select: auto !important;
        }
    
    0 讨论(0)
  • 2020-12-02 15:01

    As well as what ThinkingStiff mentioned I also use the following to remove any highlighting/copy & paste

    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0); 
    
    0 讨论(0)
  • 2020-12-02 15:11
    * {
        -webkit-touch-callout: none;
        -webkit-user-select: none; 
    }
    
    [contenteditable="true"] , input, textarea {
        -webkit-user-select: auto !important;
        -khtml-user-select: auto !important;
        -moz-user-select: auto !important;
        -ms-user-select: auto !important;
        -o-user-select: auto !important;
        user-select: auto !important;  
    }
    
    0 讨论(0)
  • 2020-12-02 15:12

    this will work too.

    <body oncontextmenu="return false" ondragstart="return false" 
    onselectstart="return false">
    
    0 讨论(0)
  • 2020-12-02 15:14

    Putting it on html, not *, works for me:

    html {
        -webkit-user-select: none;
    }
    
    0 讨论(0)
提交回复
热议问题