Capturing the onkeydown event i an IFRAME.

Discussion in 'Javascript' started by Tobias Åkeblom, Sep 15, 2003.

  1. I have a mainpage where i display my menu and an iframe for the
    content to load in. I want to trace keydown events i the Iframe. This
    works well the first time I load the site. But when I load new content
    in the iframe it seems like the eventlistner is destroyed. I can´t
    really understand why. Because the onkeydown listner in the mainpage
    is untouched.

    Here is the code. Is there a solution to my problem?

    <body>
    <div id="appCont" style="position:absolute;top:5px;left:5px">
    <iframe
    scrolling="no"
    name="appFrame"
    src="splash.jsp"
    frameborder="0"
    width="990"
    height="740">
    </iframe>
    </div>
    <script type="text/javascript">
    frames[0].document.onkeydown = function (evt) {
    whichASC=(bw.ie)?frames[0].event.keyCode:evt.which;
    alert(whichASC)
    if(whichASC==81) {
    ctrlPressed = true;
    return false;
    }
    if(whichASC==9 && ctrlPressed) {
    //do something
    }
    return true;
    };
    </script>
    </body>
    Tobias Åkeblom, Sep 15, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GP
    Replies:
    0
    Views:
    265
  2. Daedalous
    Replies:
    3
    Views:
    687
    Daedalous
    Jan 16, 2004
  3. Matthew
    Replies:
    1
    Views:
    102
    Lasse Reichstein Nielsen
    Feb 10, 2004
  4. Replies:
    10
    Views:
    324
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  5. hzgt9b
    Replies:
    3
    Views:
    274
    David Mark
    Feb 14, 2008
Loading...

Share This Page