Firefox is crashing when executing this simple function while Chrome, Safari and IE do not have any problem to execute this:
jQuery(document).ready(function($) {
if($('.fside_img').length>0) {
gundeToggling(0,2000);
}
});
function gundeToggling(prev,speed) {
// 1. Choose a victim
var victim = Math.floor(Math.random()*7); // number between 1 and 6
// 2. Check if allowed or back to 1
var alpha = $('#dn-a-'+victim);
var beta = $('#dn-b-'+victim);
var ctf_val = parseInt($('#ct_fones').val()); // Menge der sichtbaren prims
var cts_val = parseInt($('#ct_sones').val()); // Menge der sichtbaren secs
if(alpha.is(':visible') && ctf_val>2 && victim!=prev) {
alpha.fadeOut(speed);
beta.fadeIn(speed,function() {
$('#ct_fones').val(ctf_val-1);
$('#ct_sones').val(cts_val+1);
gundeToggling(victim,speed);
});
} else if(beta.is(':visible') && cts_val>2 && victim!=prev) {
beta.fadeOut(speed);
alpha.fadeIn(speed,function() {
$('#ct_fones').val(ctf_val+1);
$('#ct_sones').val(cts_val-1);
gundeToggling(victim,speed);
});
} else {
gundeToggling(prev,speed);
}
}
It is a function to fadeIn / fadeOut 6 Images by random order. I also tried to find the next images recursivley, but Firefox still crashes. What’s wrong with it?
Hello thank you for your help, the tip with setTimeout was very useful for debugging, as I could avoid the crash.
But the real problem was the following:
The :visible Selector works in Firefox different than in all other Browsers. So jQuery in Firefox thinks, that visible content blocks (missing image) were invisible, which was responsible for an endless loop as more images were invisible as the script allowed. Solution: Alt-Text for missing images 😛