1
<!DOCTYPE html>
<html lang="en">
    <head>
         <title>
         </title>
         <meta charset="utf-8" />
         <link rel="stylesheet" type="text/css" href="css/custom.css" />
    </head>
    <body>
          <iframe width="400px" src="http://www.w3schools.com"></iframe>
          <iframe width="400px" src="http://www.phpacademy.org"></iframe>
          <iframe width="400px" src="http://www.jquery.com"></iframe>
    <script type="text/javascript" src="js/jquery-3.1.1.min.js" ></script>
    <script type="text/javascript" src="js/custom.js" ></script>
    </body>
</html>

below is code in custom.js

$(window).(on.('load', function () {
    alert('All content loaded.');
}));

I want the alert to display when all the three iframes are loaded on the page.

R K
  • 307
  • 7
  • 22

2 Answers2

1

Write this way

   $(window).load(function() {
    alert("All content loaded.");
  });
Aammad Ullah
  • 274
  • 4
  • 11
  • It is generally discouraged to use event handlers like this. The preferred method is using `$(element).on('event', function() { do_something(); } )`. Besides, this does not address the problem OP has. See http://stackoverflow.com/questions/9122078/difference-between-onclick-vs-click#11878976 – connexo Nov 06 '16 at 10:48
1

The syntax you used for load is wrong, you should use

$(window).on.('load', function () {
    alert('All content loaded.');
});
RAUSHAN KUMAR
  • 5,846
  • 4
  • 34
  • 70
  • It is generally discouraged to use event handlers like this. The preferred method is using `$(element).on('event', function() { do_something(); } )`. Besides, this does not address the problem OP has. See http://stackoverflow.com/questions/9122078/difference-between-onclick-vs-click#11878976 – connexo Nov 06 '16 at 10:50