View Full Version : Onpaste doesn't work on iframe documents.

07-07-2004, 08:57 PM

I am trying to get the onpaste event to trigger for a document in an iframe. This is for IE.

document.frames.myFrame.document.body.onpaste = function () { //do whatever }

The event onpaste never triggers. Is there a way to get this working?

I am currently getting around this by using this:


And in my handleEvent function I have this:

if(keyType == "down")
if(evt.ctrlKey && evt.keyCode == 86)

This code works for me but does anyone know why the iframe onpaste event doesn't work? Is it just not supported?

Roy Sinclair
07-07-2004, 10:14 PM
Make sure you don't "hook" the event from your main page before the iframe page has finished loading. You've got to hook the event after the iframe has loaded or your event hook will be discarded.

07-08-2004, 11:48 AM
there is no onpaste event for the body. you can only do that for form elements and maybe also contentEditable divs (tho don't quote me on the latter, tho it would kinda make sense).