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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:50:38+00:00 2026-06-03T10:50:38+00:00

I have an IFrame with some buttons in it. When the buttons are clicked,

  • 0

I have an IFrame with some buttons in it. When the buttons are clicked, the parent DOM is manipulated (it’s all in the same domain, so don’t worry about the same-origin policy).

Since the user clicked on a button, the focus goes to the IFrame. However, I’d like to move the focus back to the parent document (mostly due to this FireFox problem).

How can I do this?

Edit: I’ve created a js-fiddle that shows the problem. While focus() seems to work if you call it on parent form elements, it doesn’t work in general. As you can see from the js-fiddle there are no form elements in my parent document.

  • 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-06-03T10:50:39+00:00Added an answer on June 3, 2026 at 10:50 am

    If you want to set the focus back to the outer window from inside the iframe, focussing the outer window itself is unlikely to give any visual feedback to the user, so it is better to focus a known form element in the outer page.

    You can do this as follows:

    outer.html

    <html>
      <head>
        <title>Outer</title>
      </head>
      <body>
        <iframe id="iframe" src="inner.html">
        </iframe>
      </body>
    </html>
    

    inner.html

    <html>
      <head>
        <title>Inner</title>
      </head>
      <body>
        <form id="innerForm">
          <input type="button" id="innerButton" value="Inner button" />
        </form>
      </body>
      <script type="text/javascript">
        // When we click the inner button...
        document.getElementById('innerButton').addEventListener('click', function() {
          /*
           * Do whatever you need to do here
           */
    
          // Focus the parent
          parent.focus();
        });
      </script>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iframe (same domain), and want to be able to track the
I have an editable iframe with some textnodes. During editing i want (on some
I have an IFrame app, and I would like to use some Connect features
I have some content I want to show in iframe with fancybox. When I
I have ASP.NET page with an iframe on it for displaying some pdf reports
I have a script on jquery that load some site in iframe using: $(#demo_frame).attr('src',
i know i can have iframe in a html page, say parent.htm, and i
I have an IFRAME on my web site. It's about 300px wide by 200px
I have an iframe which does some server-side work and displays an image. We
I have a page that contains an iframe element. I want to have some

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.