Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Copy and Paste in UIWebView

When a user long-press inside UIWebView, there is a Copy & Paste popup. Is it possible to disable the system from popup the Copy & Paste function, but still allow the user to click on links and goto new pages?

like image 497
ohho Avatar asked Jul 13 '11 08:07

ohho


People also ask

How do I disable copy on a website?

You can't ever disable it.. users can view the source of your page so the text is always available. If you put click handlers to disable right-click, they can turn javascript off.. The best you can try to do is make it inconvenient for people to deter them, but never can you prevent them.


1 Answers

i hope this work for you, because is work for me

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"];
    [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitUserSelect='none';"];
}
like image 121
issam Avatar answered Oct 11 '22 20:10

issam