1

I'm running into an issue when I am trying to force active DOM connections to close. Here's the code that I'm using to try to close all connections within an element:

var n, div = document.getElementById('some-div-id');
while(div && div.firstChild) {
   n = div.firstChild;
   try{
      n.removeAttribute('src');
      n.setAttribute('src','resource-that-will-return-blank-response');
   } catch (ex) {}
   try{
      div.removeChild(n);
   } catch (ex) {}
   delete n;
   n = null; 
}

The goal here would be that any active connections to remote resources (images, scripts, iframes, etc) need to be closed regardless of their current state. This seems to work in most cases (oddly enough, in all cases in IE), but there are some connections that remain alive in Firefox and Chrome, namely connections that include a redirect before hanging.

Does anyone know of a more reliable way to force DOM connections to close?

Is there something I need to do when I'm creating the elements to allow my code to force the connections to close?

David Krieg
  • 310
  • 2
  • 6

0 Answers0