I'm working on a project where they want us to prevent any of the users from pasting into the RadEditor, and I was able to get it working in IE and Firefox (finally), but Chrome just lets me paste right into the box and I cant seem to make it stop. The JavaScript I am using to prevent Pasting is as follows.
<script type=
"text/javascript"
language=
"javascript"
>
// Prevents pasting into RadEditor
// from RadEditor menu and Context menu
function
OnClientCommandExecuting(editor, args) {
var
commandName = args.get_commandName();
if
(commandName ==
"PasteFromWord"
|| commandName ==
"PasteFromWordNoFontsNoSizes"
|| commandName ==
"PastePlainText"
|| commandName ==
"PasteAsHtml"
|| commandName ==
"Paste"
) {
args.set_cancel(
true
);
}
//alert(commandName);
}
// Prevents pasting into RadEditor
// by pressing Ctrl + V
function
OnClientLoad(editor) {
editor.attachEventHandler(
"onkeydown"
,
function
(e) {
if
(e.ctrlKey && e.keyCode == 86) {
if
(document.all) {
e.cancelbubble =
true
;
e.returnvalue =
false
;
return
false
;
}
else
{
e.preventdefault();
return
false
;
}
}
});
// Prevents Firefox from loading the context menu.
editor.attachEventHandler(
"oncontextmenu"
,
function
(e) {
if
(e.preventDefault) e.preventDefault();
if
(e.stopPropagation) e.stopPropagation();
return
false
;
});
}
</script>