You are here: Reference > JavaScript > client-side > event handling > events > oncut

oncut event | cut event

Browser support:
Occurs before the selection is cut from the document and added to the clipboard.
  • In Internet Explorer, the oncut event occurs on the deepest element in the DOM hierarchy that contains the entire selection.
  • In Firefox, Google Chrome and Safari, the oncut event occurs on the deepest element in the DOM hierarchy that contains the start point of the selection.
If the oncut event is canceled, the contents of the current selection will not be cutted and placed on the clipboard. Canceling the oncut event clears the clipboard in Google Chrome and Safari.
If you need access to the clipboard, use the clipboardData object in Internet Explorer. If you need a cross-browser solution to manipulate the contents of the clipboard, see the page for the clipboardData object.

How to register:

In HTML:
<ELEMENT oncut="handler">

In JavaScript:
object.oncut = handler;
object.addEventListener ("cut", handler, useCapture);
9
object.attachEvent ("oncut", handler);
You can find the related objects in the Supported by objects section below.
The event object is accessible to all event handlers in all browsers. The properties of the event object contain additional information about the current event. To get further details about these properties and the possible event handler registration methods, please see the page for the event object.
For a complete list of events, see the page for Events in JavaScript.

Basic information:

Bubbles Yes
Cancelable Yes
Event object
DragEvent
9
Event

Actions that invoke the oncut event:

  • Pressing CTRL + X.
  • Selecting the Cut command from the Edit menu.
  • Opening the context menu (right mouse button) and selecting the Cut command.

Events related to the clipboard:

Example HTML code 1:

This example illustrates the use of the oncut event:
<head>
    <script type="text/javascript">
        function OnCut () {
            return false;   // cancels the oncut event
        }
    </script>
</head>
<body>
    Try to cut some text from the following fields:
    <br /><br />
    <input type="text" size="40" value="Cut operation is enabled" />
    <br /><br />
    <input type="text" size="40" value="Cut operation is disabled" oncut="return OnCut ()" />
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content