---
title: "iso UIWebView 禁用复制"
author: "dokero"
date: "2015-11-18T16:40:43Z"
tags: []
categories: ["移动开发"]
slug: "iso-uiwebview"
draft: false
lastmod: "2015-11-18T16:40:43Z"
id: 2257644
url: "https://dokero.iteye.com/blog/2257644"
---

为项目需要，需要在使用UIWebView载入html时，禁用在input中的copy paste Menu选项 修改Html页面 方法一： function OnLoad() { document.documentElement.style.webkitTouchCallout = "none"; //禁止弹出菜单 document.documentElement.style.webkitUserSelect = "none";//禁止选中 } 然后在body加上onload 实际测试，input并未禁止弹出复制、粘贴功能 html页面内容，禁止了复制功能 方法二： 实际测试，禁止了弹出复制、粘贴功能，但键盘输入也无法在显示在webView的input中。 修改iOS代码： 方法一： - (void)webViewDidFinishLoad:(UIWebView \*)webView { // Disable user selection \[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"]; // Disable callout \[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"]; } 实际测试，input并未完成禁止弹出复制、粘贴功能 html页面内容，禁止了复制功能 方法二： 获得UIMenuController，然后强行隐藏menu item的view， 实际测试，有效果，估计不能提交到app store