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 6248935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:08:56+00:00 2026-05-24T13:08:56+00:00

I have a main page in which I have an iframe I have bound

  • 0

I have a main page in which I have an iframe
I have bound a function to be executed whenever the main page gets focus (that will
be after the user, opens another tab or window and then comes back to the page)

When the user clicks on a button inside the main page, an iframe opens, and if that iframe is posted back or reloads, then the focus event of the main page stops working.

In the following code, I have tried an alternate solution, by rebinding the focus event to the main page’s window whenever the contents of the iframe are reloaded. But, still it is not able to bind the focus event again to the main page’s window.

Can somebody please help ??

 $(document).ready(function() {
            $(window).focus(function() {
                CheckChange();
            });
            $("iframe").load(function() {
                alert('1');
                alert(top.window);
                $(top.window).focus(function() {
                    alert('2');
                    CheckChange();
                });
            });
        });
  • 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-24T13:08:57+00:00Added an answer on May 24, 2026 at 1:08 pm

    I got its answer, after I open the iframe in the main page, and then switch between the browser tabs, the item which gets focus is the iframe itself and the parent window never gets focus, that’s why its focus event is not called. What gets called is the focus event of the iframe, which I tried very hard to attach to iframe but, eventually I found out that with jquery, the focus event handler was not getting attached to iframe, I declared everywhere in my html pages on each iframe element explicitly the "onfocus=eventHandler" attribute and then the iframe started getting focus while switching between the browser tabs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main page which contains a simple iframe. Iframe source = a
I have a page which contains an iframe. My problem is that I sometimes
I have a main page (main.html) which opens an iframe page (iframe.html).. The iframe
I'm developing a facebook iframe app (page app), which counts the user's friends that
I have a page (main.php) which loads content from an external PHP file (rpc.php).
On my main page I have this jquery code which does an ajax call
I have an PHP/HTML main page, in which I include different other PHP files
I have a login form, which needs to be re-directed to the main page
I have a window(say main window) with a frame which has a page in
The Idea I have a main PHP page that loads content in DIV's from

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.