Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Onpaste doesn't work on iframe documents.

    Hello,

    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:

    Code:
    myObject.cw.document.attachEvent('onkeydown',function(e){handleEvent(e,"down")},true);
    And in my handleEvent function I have this:
    Code:
    if(keyType == "down")
    {
          if(evt.ctrlKey && evt.keyCode == 86)
          {
               handlePaste();
         }
    }
    This code works for me but does anyone know why the iframe onpaste event doesn't work? Is it just not supported?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •