LaLaLa Posted July 26, 2009 Report Share Posted July 26, 2009 (edited) I have created some code that collapses a <div> smoothly, changes the inner HTML, and then reopens the <div> smoothly. The code works perfectly in Internet Explorer 8, but stops after the first resize in FireFox 3.5 and doesn't continue looping. No errors are returned by either browser. Here is the java script: <script type="text/javascript"> function section_change(var_section_parameter) { var_section=var_section_parameter; section_visible(document.getElementById("section_content_div").offsetHeight,-1); } function section_visible(var_original_height,var_direction) { if(var_direction==-1) { if(document.getElementById("section_content_div").offsetHeight>0) { var_change=(-((document.getElementById("section_content_div").offsetHeight-var_original_height/2)*(document.getElementById("section_content_div").offsetHeight-var_original_height/2))+var_original_height*var_original_height/4)/1200+1; document.getElementById("section_content_div").style.height=(document.getElementById("section_content_div").offsetHeight-var_change)+"px"; document.getElementById("section_content_border_left").style.height=(document.getElementById("section_content").offsetHeight-var_change)+"px"; document.getElementById("section_content_border_right").style.height=(document.getElementById("section_content").offsetHeight-var_change)+"px"; document.getElementById("main_border_left").style.height=(document.getElementById("main").offsetHeight-var_change)+"px"; document.getElementById("main_border_right").style.height=(document.getElementById("main").offsetHeight-var_change)+"px"; document.getElementById("title").style.opacity=document.getElementById("section_content_div").offsetHeight/var_original_height; document.getElementById("title").filters.alpha.opacity=document.getElementById("section_content_div").offsetHeight/var_original_height*100; setTimeout("section_visible("+var_original_height+","+var_direction+");",30); } else { setTimeout("section_change_continue();",500); } } else if(var_direction==1) { if(document.getElementById("section_content_div").offsetHeight<var_original_height) { var_change=(-((document.getElementById("section_content_div").offsetHeight-var_original_height/2)*(document.getElementById("section_content_div").offsetHeight-var_original_height/2))+var_original_height*var_original_height/4)/1200+1; document.getElementById("section_content_div").style.height=(document.getElementById("section_content_div").offsetHeight+var_change)+"px"; document.getElementById("section_content_border_left").style.height=document.getElementById("section_content").offsetHeight+"px"; document.getElementById("section_content_border_right").style.height=document.getElementById("section_content").offsetHeight+"px"; document.getElementById("main_border_left").style.height=document.getElementById("main").offsetHeight+"px"; document.getElementById("main_border_right").style.height=document.getElementById("main").offsetHeight+"px"; document.getElementById("title").style.opacity=document.getElementById("section_content_div").offsetHeight/var_original_height; document.getElementById("title").filters.alpha.opacity=document.getElementById("section_content_div").offsetHeight/var_original_height*100; setTimeout("section_visible("+var_original_height+","+var_direction+");",30); } } } function section_change_continue() { if(var_section=="Game Maker") { //Change innerHTML... } document.getElementById("section_content_div").style.height="100%"; var_new_height=document.getElementById("section_content_div").offsetHeight; document.getElementById("section_content_div").style.height="0px"; section_visible(var_new_height,1); } </script> The "section_change("Game Maker");" function is called when an anchor is clicked. Edited August 6, 2009 by LaLaLa Link to comment Share on other sites More sharing options...
justsomeguy Posted July 27, 2009 Report Share Posted July 27, 2009 Add some debugging code to print out the values of the various variables. Print any value used in an if statement, print the parameters you're sending to the functions, the offsets, etc. You can use that information to step through the code and figure out why Firefox is doing what it does. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now