1

The below code does not alert the message in firefox especially version - 39.0.

$(document).ready(function(){
    $('#test').load(function(){
            alert('loaded');
    });
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<img class="content_tag" id="test" src="ACTUAL IMAGE PATH"/>
Sanjay Kumar N S
  • 4,653
  • 4
  • 23
  • 38

1 Answers1

3

First of all Your jquery library should be before your code like this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $('#test').attr('src', 'http://www.youtube.com/v/h60r2HPsiuM');
    $('#test').load(function(){
            alert('loaded');
    });
});
</script>
<img class="content_tag" id="test" src="ACTUAL IMAGE PATH"/>

Please check this out Bug #11733 and SO discussion on this bug which states that .load() is depreciated now and .on('load') replaces it.

$('#test').on('load',function(){
     alert('loaded');
});
Community
  • 1
  • 1
Rohit Arora
  • 2,246
  • 2
  • 24
  • 40
  • But that doesnt solved my problem. Can you check the fiddle - http://jsfiddle.net/sanjaykumarns/4x4uLmzu/3/ which is working in chrome but not in firefox 39.0. – Sanjay Kumar N S Aug 04 '15 at 05:05
  • @SanjayKumarNS I have checked your fiddle in version 39.0 of firefox also, For me it is working fine for every version and browser. – Rohit Arora Aug 04 '15 at 05:08
  • Thanks Rohit Arora for the reply. I found the solution that, in firefox, .load() should contain the first parameter should be the url- like this - http://jsfiddle.net/sanjaykumarns/4x4uLmzu/4/ – Sanjay Kumar N S Aug 04 '15 at 05:27
  • @SanjayKumarNS Checkout my edit now. Because passing url to load function is not the correct solution as it is another method to load something in your specific element. – Rohit Arora Aug 04 '15 at 05:40