Android 如何在Webview中实现自己的SelectAll、剪切、复制和粘贴
我正在使用WebView实现富编辑文本,编辑器操作的按钮显示在上下文操作栏(CAB)中,长按WebView时,它的默认CAB显示为按钮,我知道WebView没有提供任何自定义其CAB的规定 所以我认为最好实现选择、剪切、复制、粘贴操作。 我已经试过了,但没有成功 我的应用程序针对的是android 3.x+设备 请建议我如何做。我使用javascript库来做这件事。对于剪切、复制和粘贴操作,我注入了自己的javascriptAndroid 如何在Webview中实现自己的SelectAll、剪切、复制和粘贴,android,webview,contextual-action-bar,richeditabletext,Android,Webview,Contextual Action Bar,Richeditabletext,我正在使用WebView实现富编辑文本,编辑器操作的按钮显示在上下文操作栏(CAB)中,长按WebView时,它的默认CAB显示为按钮,我知道WebView没有提供任何自定义其CAB的规定 所以我认为最好实现选择、剪切、复制、粘贴操作。 我已经试过了,但没有成功 我的应用程序针对的是android 3.x+设备 请建议我如何做。我使用javascript库来做这件事。对于剪切、复制和粘贴操作,我注入了自己的javascript 全选-(函数(){document.execCommand('se
- 全选-
(函数(){document.execCommand('selectall',true,null);})(
- Cut-
(函数(){document.execCommand('Cut',true,null);})(
- Copy-
(函数(){document.execCommand('Copy',true,null);})(
- 粘贴-
document.execCommand('insertHtml',false',“+text + "');代码>文本是从剪贴板复制的数据
- 全选-
(函数(){document.execCommand('selectall',true,null);})(
- Cut-
(函数(){document.execCommand('Cut',true,null);})(
- Copy-
(函数(){document.execCommand('Copy',true,null);})(
- 粘贴-
document.execCommand('insertHtml',false',“+text + "');代码>文本是从剪贴板复制的数据
谢谢。注意,由于跨源安全策略,这在不同域的文档中的iFrame中不起作用。注意,由于跨源安全策略,这在不同域的文档中的iFrame中不起作用。