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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:09:14+00:00 2026-05-27T01:09:14+00:00

My script loads an iframe when the user clicks a button. I want to

  • 0

My script loads an iframe when the user clicks a button. I want to call another function after the iframe loads, but it’s not working. The iframe does load normally, but the .load() event never gets called after the iframe finishes loading. The iframe contains content from the same website (no external content). The strange thing is that I’m using the same technique described below at a few other points in my code and it works perfectly. Can anyone suggest what I should check next?

Here’s the relevant code:

$('#myIframe').load(function () {
    alert('iframe loaded');
});

$('#someButton').live('click', function () {
    $('body').append($('<iframe id="myIframe" src="https://www.mywebsite.com" width="100%"></iframe>'));
});
  • 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-27T01:09:15+00:00Added an answer on May 27, 2026 at 1:09 am

    Seems somewhat similiar to the question here:

    jQuery .ready in a dynamically inserted iframe

    This way the Iframe element exists in the Dom with the append. Only when you set the Url will it load, by which point you’ve attached the load function you wish to tag on the end.
    So for your code

    $('#someButton').live('click', function () {
    
        $('body').append($('<iframe id="myIframe" width="100%"></iframe>'));
        $('#myIframe').attr('src',"https://www.mywebsite.com");
    
        $('#myIframe').load(function () {
            alert('iframe loaded');
        });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script which loads content into a iframe using: document.GetElementById('iframeid').src = 'site.html';
I'm trying to detect when an iframe and its content have loaded but not
I have a CodeIgniter script which loads a fancybox iframe with a form in
Is it possible to call a php function when an html radio button is
I have an IFrame inside my 1st page that loads another page which I
I've got an iframe application that's working fine and rendering fbml in facebook. But
I have a script that dynamically loads iframes inside a webpage. You can see
I have a java script function that i have called on body load mousemove()
This is how I load jQuery: <script src=http://www.google.com/jsapi></script> <script type=text/javascript> function OnLoad() { insert
I just found the joy of communicating from one iframe to another using html5's

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.