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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:13:29+00:00 2026-06-11T11:13:29+00:00

I am trying to check whether an iframe has loaded after the user clicks

  • 0

I am trying to check whether an iframe has loaded after the user clicks a button.

I have

$('#MainPopupIframe').load(function(){
    console.log('load the iframe')
    //the console won't show anything even if the iframe is loaded.
})

HTML

<button id='click'>click me</button>

//the iframe is created after the user clicks the button.
<iframe id='MainPopupIframe' src='http://...' />...</iframe>

Any suggestions?

By the way, my iframe is created dynamically. It doesn’t load with the initial page load.

  • 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-11T11:13:31+00:00Added an answer on June 11, 2026 at 11:13 am

    You may try this (using jQuery)

    $(function(){
        $('#MainPopupIframe').load(function(){
            $(this).show();
            console.log('iframe loaded successfully')
        });
            
        $('#click').on('click', function(){
            $('#MainPopupIframe').attr('src', 'https://heera.it');    
        });
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <button id='click'>click me</button>
    
    <iframe style="display:none" id='MainPopupIframe' src='' /></iframe>

    jsfiddle DEMO.

    Update: Using plain javascript

    window.onload = function(){
        var ifr = document.getElementById('MainPopupIframe');
        ifr.onload=function(){
            this.style.display='block';
            console.log('laod the iframe')
        };
    
        var btn = document.getElementById('click');    
        btn.onclick=function(){
            ifr.src='https://heera.it';    
        };
    };
    <button id='click'>click me</button>
    
    <iframe style="display:none" id='MainPopupIframe' src='' /></iframe>

    jsfiddle DEMO.

    Update: Also you can try this (dynamic iframe)

    $(function(){
        $('#click').on('click', function(){
            var ifr = $('<iframe/>', {
                id:'MainPopupIframe',
                src:'https://heera.it',
                style:'display:none;width:320px;height:400px',
                load:function(){
                    $(this).show();
                    alert('iframe loaded !');
                }
            });
            $('body').append(ifr);    
        });
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <button id='click'>click me</button><br />

    jsfiddle DEMO.

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

Sidebar

Related Questions

I'm trying to check whether user has installed my application or not. The flow
I am trying to check whether a radio button has been clicked on my
I have been trying to check whether an NSInteger is odd or even. I
I'm trying to check whether val() has a specific value or not inside a
I am trying to check whether a list contains a value, which is user
I'm trying to check whether a function exists or not but I keep getting
I am trying to create a jQuery function to check whether a Cancel or
I'm trying to check whether an input contains a URL either when a user
I am trying to check whether an #include <file.h> has already been declared using
I'm trying to check whether a user is attending an event within a list

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.