Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

Call a parent window function from an iframe

  • Last Updated : 19 Jul, 2019

Did you ever want to call a code/website that belongs to the parent window, and that too from the child window? Well, some good news for new. You will be able to do your desired job. The window will get opened by using the iframe, and the communication could be done with the parent window from the child window.

To call a parent window function, use the following syntax and also refer to the code given below.

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

<a onclick=";" href="#" > Call the parent window here </a>

Example :

<!DOCTYPE html>
    <title>Calling a parent window function from an iframe</title>
    <script type="text/javascript"
    <script type="text/javascript">
        $(function() {
            $('[id*=iframe1]').load(function() {
                //call here your javascript function
        function myfunction() {
            alert('Function called after the IFrame load')
        <h2 style="color:green">GeeksforGeeks</h2>
        <p>Calling a parent window function from an iframe</p>
        <form id="form1" runat="server">
                <!-- Calling a parent window function from an iframe -->
                <iframe id="iframe1" src=""
                        width="600" height="450" frameborder="0"
                              style="border:0" scrolling="no"></iframe>


My Personal Notes arrow_drop_up
Recommended Articles
Page :