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

  • SEARCH
  • Home
  • 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 7400761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:17:52+00:00 2026-05-29T04:17:52+00:00

My problem is I need to capture a keypress but at any given time

  • 0

My problem is I need to capture a keypress but at any given time the user can be inside of an iframe inside of an iframe inside of an iframe.

At first, I thought I could just put the listener on document but that doesn’t work if the user is inside of one of those iframes.

Next I thought of attaching the handler to window but ie doesn’t support attaching event handlers to window. I’m not even sure if that would work though or it would be the same problem as with document.

Next, I thought I could just go through all the iframes and add individual handlers there but eventually realized that wouldn’t work because the iframe doesn’t have any html in the dom so there is no way to access iframes nested in it.

One other possible solution is to go to the js of all the iframes and add this code manually but that is way too extreme.

Any other ideas?

  • 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-29T04:17:53+00:00Added an answer on May 29, 2026 at 4:17 am

    I keep answering my own questions but oh well. If you come across this problem I figured out the answer. This uses jquery but you could port it to straight js if you had to.

    var myFunction = function () {
                alert("hello world");
            };
            var $myWindow = $(myWindow /*dom object*/);
            $myWindow.bind("mouseover", myFunction);
            var getNested_iframes = function (document_element) {
                $.each(document_element.find("iframe"), function () {
                    var iframeDocument = $(this).get(0).contentWindow.document; // may need to change this depending on browser
                    iframeDocument.onkeyup = myFunction;
                    getNested_iframes($(iframeDocument));
                });
            }
            getNested_iframes($myWindow);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem here and need your help. I've been trying to capture
I've been given a problem that I need some assistance from the SO community
I need to capture an image of panel. The problem I am running into
The Problem: I need to receive different types of content from a number of
An XSLT-newbie problem: I need to substitute a text value in XML-file. All other
This is my problem: I need to store a lot of log messages and
To solve some problem I need to compute a variant of the pascal's triangle
I faced a problem - I need to use a macro value both as
I have the following problem: We need to find the next august. I other
I have the following problem: I need to use XSLFO to generate a 2-column

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.