¿Alguien puede decirme por qué el setTimeout utilizado en el siguiente código no funciona? Simplemente ejecuta la función de inmediato.SetTimeout no retrasa una llamada de función
function change_txt_font(elem, id, text_fnt){
current_width = parseInt($('#span_text'+id).css('width'));
current_height = parseInt($('#span_text'+id).css('height'));
current_font_size = parseInt($("#span_text"+id).css("font-size"));
parent.document.getElementById(elem+'_f').value=text_fnt;
$('#span_text'+id).css('font-family',text_fnt);
$('#'+elem).css('font-family',text_fnt);
setTimeout(adjust_for_font(id),2000);
}
function adjust_for_font(id){
alert("function")
alert("id = "+id)
new_height = parseInt($('#span_text'+id).css('height'));
new_width = parseInt($('#span_text'+id).css('width'));
width_ratio = parseFloat(current_width/new_width)
height_ratio = parseFloat(current_height/new_height)
new_font_size = current_font_size * Math.min(width_ratio,height_ratio)
$("#text"+id).css("font-size", (parseFloat(new_font_size) - 1) + "px");
$("#span_text"+id).css("font-size", (parseFloat(new_font_size) - 1) + "px");
document.getElementById("form_front_text"+id).submit();
}document.getElementById("form_front_text"+id).submit();
}
Cualquier ayuda apreciada.
'setTimeout (function() {adjust_for_font (id);}, 2000)' – Sim
Gracias Sim your a star! Todavía me estoy acostumbrando a javascript, ¡y se muestra a veces! Gracias de nuevo. –