12
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iframeのonload呼び出し順

Last updated at Posted at 2018-02-21

iframeの読み込みが完了後、onloadが動作するのか検証
すぐ読み込みが完了してしまうとテストできないので、iframeの読み込みを5秒遅らせる

iframe呼び出し先
<?php
sleep(5);//5秒待機
echo 'iframetest';
?>
<html>
  <script type="text/javascript">
     alert('一番初めに実行されます');
   </script>
</html>
iframe呼び出し元
    <body>
        <iframe onload="alert('2番目に実行されます')" src="//***">
        </iframe>

        <script type="text/javascript">
            $(window).load(function() {
                alert("最後に実行されます");
            });
        </script>
    </body>

##結果

  1. iframeの読み込み
  2. iframeの読み込み完了後、iframeのonload
  3. 最後にwindow onload
12
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?