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 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2004
    Location
    St. Louis
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    iframes and onkeydown, compatible?

    Are iframes compatible with onkeydown? Let me back up and make this harder (or easier?)... Can I use onkeydown on and iframe that is in docmode (designmode)? If I can, can I interpret only the keystroke I want ("esc") and the rest will go through to the iframe in docmode?

    I have a help system that runs on local machines. It has a 2 frame page that comes up to browse (left side) and diplay (right side) data. I want to be able to parent.window.close() when they press "ESC." I got it working everywhere EXCEPT when they are in the editable iframe. The editable iframe is what they use to create they're own helps.

    In summary I want to catch the "ESC" key in an EDITABLE (that's what's making it hard) iframe and use that to close the window and let every other keystroke go by.

    Ideas??

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer

    quickly tried this; seems to work...

    Code:
    <body onload="ifr.document.designMode='on'">
    <iframe id="ifr" src="about:blank" width="25%" height="25%"></iframe>
    <script type="text/JScript">
    function ifr.document::onkeypress(){
    if(event.keyCode == 27){alert("ESC");}
    }
    </script>
    </body>
    hmm... ?

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    swmr's idea will work right up to the point where you load a document into the iframe, then you'll have to link up the events in the iframe to your functions again.

    You have to remember that an IFRAME is like a separate browser window that's just embedded inside your web page. What's contained within that iframe isn't part of your page, you can hook events from that iframe to your page as long as the iframe is looking at a page from your web server, otherwise you can't hook it's events since that would allow cross-site scripting.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #4
    New Coder
    Join Date
    Feb 2004
    Location
    St. Louis
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that should work because I dynamicaly control the page being built into the iframe anyway...


  •  

    Posting Permissions

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