Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

webview no selection/copy&paste

hi everyone.
Is it possible to disable the possibility to select text in the webview where you can copy the selected text without disabling the scrolling on iPhone?

I found no solution.

Thanks

— asked September 20th 2010 by Sascha Löffler
  • copy
  • iphone
  • mobile
  • selection
  • webview
0 Comments

3 Answers

  • Accepted Answer

    yes, in the html of the page you need use CSS for the element( let's say body) you want not to be selectable

    -webkit-user-select: none;
    
    — answered September 20th 2010 by Dan Tamas
    permalink
    1 Comment
    • hey dan this is only for ios for android you need to add this code—->

      webview.addEventListener('longpress', function(e) { return false; });

      webview.addEventListener('longclick', function(e) { return false; });

      — commented October 10th 2012 by Arun Shejul
  • use this—–>

    webview.addEventListener('longpress', function(e) {
    return false;
    });

    webview.addEventListener('longclick', function(e) {
    return false;
    });

    — answered October 9th 2012 by Arun Shejul
    permalink
    1 Comment
    • and for ios we can add this css———>

      • {
        -webkit-touch-callout: none;
        -webkit-user-select: none; / Disable selection/Copy of UIWebView /
        }

      — commented October 10th 2012 by Arun Shejul
  • please use this —>

    webview.addEventListener('longpress', function(e) {
    alert("you can't select text…!");
    });

    — answered October 9th 2012 by Arun Shejul
    permalink
    2 Comments
    • word of warning - this disables scrolling in iOS.

      — commented April 4th 2013 by Delete Me
    • yeap i know but its only android specific code
      and for IOS use "-webkit-user-select: none;"

      — commented April 8th 2013 by Arun Shejul
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.