Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3627506
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:53:50+00:00 2026-05-18T23:53:50+00:00

I have a jsp page with frames <%@ include file=/includes/taglibs.jsp%> <!DOCTYPE HTML PUBLIC -//W3C//DTD

  • 0

I have a jsp page with frames

<%@ include file="/includes/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
  <head>
  <title>Welcome</title>
    <script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $(this).keydown(function(e) {
                if(e.keyCode==27){
                    alert("escape pressed");
                    e.preventDefault();
                }
          });       
        }   
        );  
      </script> 
  </head>
      <frameset rows="42,*" frameborder="0" framespacing="0" id="framest">
          <frame src="/xyz/abc.html" scrolling="no" name="frame1"/>
          <frame src="/xyz/init.html" scrolling="no" name="frame2"/>
      </frameset>
</html>

I am trying to capture escape key press. But this doesn’t seem to work. On each individual frame html if I write the same code of capturing , it works perfectly fine.

What changes should I make in the code above so that I would write the keydown code just once which enables me to capture keydown on anywhere on page on any frame.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T23:53:50+00:00Added an answer on May 18, 2026 at 11:53 pm

    Remember a frame is a completely new HTML page with a whole separate DOM, so jQuery doesn’t include it in your bindings.

    So you will need to bind to those documents also:

    function keyDownHandler(e) {
        if(e.keyCode==27){
            alert("escape pressed");
            e.preventDefault();
        }
    }
    
    for (var id in window.parent.frames)
        $(window.parent.frames[id].document).keydown(keyDownHandler);
    $(document).keydown(keyDownHandler);
    

    If the above doesn’t work for you because of the id:

    for (var i = 0; i < window.parent.frames.length; i ++) {
       var frame = window.parent.frames[i].document;
       frame.addEventListener("keydown",keyDownHandler, true);
    }
    

    If you want to reference all frames, from the top level

    for (var i = 0; i < top.window.frames.length; i ++) {
       var frame = top.window.frames[i].document;
       frame.addEventListener("keydown",keyDownHandler, true);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jsp page with two radio tags. The page contains a struts2
Right now I have a JSP page that allows to sort some items, when
I have this simple Jsp page: <%@ page language=java import=java.awt.Color%> <% Color background =
I have a list of bean objects passed into my JSP page, and one
On a JSTL/JSP page, I have a java.util.Date object from my application. I need
I have an application web.xml with the following entry: <error-page> <error-code>404</error-code> <location>/system_files/error/p_notfound.jsp</location> </error-page> However,
I am changing a GET to a POST. Currently I have .jsp?id=a,b,c,d. When changing
I have a JSP that is using Spring:form tags to bind controls to a
I have a JSP which attaches a XSL to an XML document pulled from
I'm running tomcat and have some jsp pages that display a subset of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.