FireFox Never Stops Loading With iFrame Submission

Posted August 27, 2008 at 9:40 AM

Tags: ColdFusion, Javascript / DHTML

A while back, I created an AJAX file upload demo using jQuery and ColdFusion. The demo worked quite nicely, but people using FireFox 3 were telling me that FireFox never stopped loading. That is, the page would execute fine, but the window would signal (via the Status Bar and loading circle) that it never completed loading the page. Based on some feedback from Josh, I narrowed the problem down to the removal of the iFrame from the page during its own load callback:

 Launch code in new window » Download code as text file »

  • jFrame.load(
  • function( objEvent ){
  • ..... CODE TO PROCESS .....
  •  
  • // Remove iFrame from page.
  • jFrame.remove();
  • }
  • );

Something about removing the iFrame as part of the its own load() event binding was causing issues. To get around this, all I had to do was add a slight delay to the actual removal of the iFrame:

 Launch code in new window » Download code as text file »

  • jFrame.load(
  • function( objEvent ){
  • ..... CODE TO PROCESS .....
  •  
  • // Remove the iFrame from the document.
  • // Because FireFox has some issues with
  • // "Infinite thinking", let's put a small
  • // delay on the frame removal.
  • setTimeout(
  • function(){
  • jFrame.remove();
  • },
  • 100
  • );
  • }
  • );

By delaying the iFrame removal for a tenth of a second (could have been smaller), it seems to allow the load() event to execute properly without causing any hanging on the page. FireFox acknowledges that the iFrame has in fact stopped loading once the load() event has finished executing. Then, once it's done executing, we can then safely remove the iFrame from the page.

I am sure that there are a number of scenarios that would cause FireFox to never stop loading, but this is a solution to one of them.

Download Code Snippet ZIP File

Post Comment  |  Ask Ben  |  Permalink  |  Other Searches  |  Print Page


You Might Also Be Interested In:



Learning ColdFusion 9 - ColdFusion 9 tutorials, samples, examples, demos

Reader Comments

Aug 27, 2008 at 10:41 AM // reply »
153 Comments

I've gotten to the point in my code where absolutely any removal of a DOM object is done asynchronously. Too many browsers do strange things where you remove an object and it is in any way tied via an event to the code you are currently running.

Yeah, it's paranoia. Yeah, it's cargo cult. But as the example above shows, it's a line or two of code that prevents hours of debugging headaches.


Aug 27, 2008 at 11:01 AM // reply »
6,516 Comments

@Rick,

Better to be paranoid than have to exhaustively test on every browser and version ever made :) I like your style.


Aug 28, 2008 at 3:19 AM // reply »
1 Comments

"Based on some feedback from Josh, I narrowed the problem down to the removal of the iFrame from the page during its own load callback"

Doctor, I think this man has Apple Fever. ;)


Aug 28, 2008 at 8:13 AM // reply »
6,516 Comments

@Craig,

Ha ha :) Good catch.


Dec 6, 2008 at 1:53 PM // reply »
1 Comments

Thank you a lot! Simple and clean! :D


Jan 2, 2009 at 4:39 PM // reply »
1 Comments

Thanks a bunch! This also saved my day!


Oct 27, 2009 at 9:45 PM // reply »
1 Comments

Worked like a charm! Thanks! I was wondering what was going on with the constantly loading Firefox tab.

Great transaction, great seller, would recommend (A+++).


Post Comment  |  Ask Ben

Recent Blog Comments
Nov 22, 2009 at 1:56 AM
Learning ColdFusion 9: Using CFQuery In CFScript Can Enable SQL Injection Attacks
Why adobe would give you script equivalent of cfquery is beyond me. I love cfquery tag because it helps me wriite clean sql, and get away from the horrible jdbc queries If I wanted to write javali ... read »
Nov 22, 2009 at 1:45 AM
Streaming Text Using ColdFusion's CFContent Tag And The Variable Attribute
The reason you would want to do this is to stream. Ack json/xml files to ria clients I used thus technique before because putting json in response stream causes debugging info to come thru As well a ... read »
Nov 21, 2009 at 6:47 PM
Hal Helms - Real World Object Oriented Development, Sarasota - Day Five
@charlie griefer, Thank you.. ... read »
Nov 21, 2009 at 5:15 PM
Using ColdFusion Structures To Remove Duplicate List Values
@Jose Galdamez, Oh heh yeah I didn't paste the whole code. I should have defined the vars -- my bad. It's fixed thou. Thanks. ... read »
Nov 21, 2009 at 4:49 PM
Styling The ColdFusion 8 WriteToBrowser CFImage Output
Great work yet again Ben! Whilst I didn't use this whole code, I copied some of your regex code for a similar problem with the lack of an alt attribute and unescaped ampersands in CFIMAGE for Railo 3 ... read »
Nov 21, 2009 at 1:13 PM
My First ColdFusion Builder Extension - Encrypting And Decrypting CFM / CFC Files
@Ben, Because I am pedantic, I just want to make sure that everyone knows there is absolutely no encryption going on. There is only encoding and obfuscation. The cfencode tool only obfuscates your C ... read »
Nov 21, 2009 at 12:28 PM
Using ColdFusion Structures To Remove Duplicate List Values
@Jody I can't seem to get your code sample to work. If you are still having problems, try this code out and see if it gets you what you wanted. <!--- Comma delimited list with various duplicates ... read »
Nov 21, 2009 at 11:03 AM
Groovy Operator Overloading Does Not Work In The ColdFusion Context
Hi Ben, Thanks for this informative post. Now I am reading ur old posts too ... read »