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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:45:40+00:00 2026-05-27T13:45:40+00:00

I have a page that contains a dynamically loaded <iframe> . This iframe contains

  • 0

I have a page that contains a dynamically loaded <iframe>. This iframe contains a <form>.
When the user submits the <form>, a new page is loaded within the <iframe> saying Thanks.

Instead of using a second page, i want the parent page to show the Thanks message.

So basically i am in my <iframe>, and i want to call a function on the parent frame.

How can i do that ?

  • 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-27T13:45:41+00:00Added an answer on May 27, 2026 at 1:45 pm

    I’ve done a little example for you.

    Here is the main page (index.html) containing the iframe

    <html>
        <head>
            <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
        </head>
        <body>
            <input type="hidden" id="infoFormPosted" value=0 />
            <iframe src="./iframe.html"></iframe>
            <div id="thanks" style="display:none;">
                Thanks!
            </div>
        </body>
    </html>
    

    And here is the iframe (iframe.html):

    <html>
        <head>
            <title>myIframe</title>
            <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
             <script type="text/javascript">
             $(document).ready(function() {
                $("#infoForm").submit(function() {
                  //change the value of the top document input hidden to 1
                  $("#infoFormPosted", top.document).val(1);
                });
                // if the input hidden is set to 1
                if($("#infoFormPosted", top.document).val() == 1){
                    // show the thanks div on the top document (not in the iframe)
                    $("#thanks", top.document).show();
                }
            });
    
            </script>
        </head>
        <body>
            <div id="anydiv">
                <form id="infoForm" action="#" method="post">
                  First name: <input type="text" name="fname" /><br />
                  Last name: <input type="text" name="lname" /><br />
                  <input type="submit" value="Submit" />
                </form> 
            </div>
        </body>
    </html>
    

    EDIT : An alternative is to create a function inside the main page and call it in the iframe using parent.nameOfTheFunction()

    The main page (index.html)

    <html>
        <head>
            <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
            <script type="text/javascript">
            showThanks = function(){
                $("#thanks").show();
            };
    
            </script>
        </head>
        <body>
            <input type="hidden" id="infoFormPosted" value=0 />
            <iframe src="./iframe.html"></iframe>
            <div id="thanks" style="display:none;">
                Thanks!
            </div>
        </body>
    </html>
    

    The iframe (iframe.html):

    <html>
        <head>
            <title>myIframe</title>
            <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
             <script type="text/javascript">
             $(document).ready(function() {
                $("#infoForm").submit(function() {
                  //change the value of the top document input hidden to 1
                  $("#infoFormPosted", top.document).val(1);
                });
                // if the input hidden is set to 1
                if($("#infoFormPosted", top.document).val() == 1){
                    // call showThanks function from the main frame
                    parent.showThanks(); 
                }
            });
    
            </script>
        </head>
        <body>
            <div id="anydiv">
                <form id="infoForm" action="#" method="post">
                  First name: <input type="text" name="fname" /><br />
                  Last name: <input type="text" name="lname" /><br />
                  <input type="submit" value="Submit" />
                </form> 
            </div>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASPX Page that contains several user controls, which are loaded dynamically
I have a page that contains a form, where part of it is dynamically
I have a page in a site that contains an iframe with a form
I have a page that contains a user control that is just a personalized
I would like to have an aspx page that contains something like.... <form id=form1
I have an ASP.Net page that contains a <div> with an <img> tag within.
I have a pre tag within my page that contains quite a bit of
I have a page that contains dynamically generated Dropdown List controls and I want
I have a page with 80+ dynamically generated input boxes, when the user submits
Here's the problem....I have three components...A Page that contains a User Control and 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.