Is it possible to use iframes in IE without memory leaks?

后端 未结 4 961
野的像风
野的像风 2020-12-05 03:13

All versions of IE (including 10) appear to hold on to a significant amount of memory allocated by iframes until window.top.unload occurs. This creates quite the challenge f

4条回答
  •  日久生厌
    2020-12-05 03:38

    Have a try with this:

    collectGarbageForIframe: function() {
      var $iframes = $("*[tag='iframe']");
      $iframes.each(function() {
        var $target = $(this);
        if($target.length>0) {
          $target[0].src = "about:blank";
          $target[0].contentWindow.document.write('');
          $target[0].contentWindow.close();
          $target.remove();
          if( typeof CollectGarbage == "function") {
            CollectGarbage();
          }
        }
      });
    }
    

提交回复
热议问题