Web site developers - 324Part IIIDocument Objects ReferenceExampleYou can use the onbeforecopyevent

324Part IIIDocument Objects ReferenceExampleYou can use the onbeforecopyevent handler to preprocess information prior to an actual copyaction. In Listing 15-33, the function invoked by the second paragraph element s onbeforecopyevent handler selects the entire paragraph so that the user can select any character(s) in theparagraph to copy the entire paragraph into the clipboard. You can paste the results into thetext area to verify the operation. By assigning the paragraph selection to the onbeforecopyevent handler, the page notifies the user about what the copy operation will entail prior to mak- ing the menu choice. Had the operation been deferred to the oncopyevent handler, the selec- tion would have been made after the user chose Copy from the menu. Listing 15-33: The onbeforecopy Event Handler

onbeforecopy Event Handler


Select one or more characters in the following paragraph. Then executea Copy command via Edit or context menu.

Lorem ipsum dolor sit amet, consectetaur adipisicing elit, sed do eiusmod tempor incididunt utlabore et dolore magna aliqua. Ut enim adminim veniam, quis nostrudexercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Paste results here:

Related Items:onbeforecut, oncopyevent handlers. onbeforecutCompatibility:WinIE5+, MacIE-, NN-, Moz-, Safari- The onbeforecutevent handler fires before the actual cut action takes place whenever theuser initiates a content cut via the Edit menu (including the Ctrl+X keyboard shortcut) or theright-click context menu. If the user accesses the Cut command via the Edit or context menu, the onbeforecutevent fires before either menu displays. In practice, the event may fire twiceeven though you expect it only once. Just because the onbeforecutevent fires, it does notelementObject.onbeforecopy

Leave a Reply