[Pkg-javascript-commits] [sockjs-client] 235/434: Fix for Onunload not being triggered in ie7 and ie8.

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:16 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit 5f793543344f7b0eda9da9765a7bfc1b9f01b1a9
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Thu Dec 1 11:49:11 2011 +0000

    Fix for Onunload not being triggered in ie7 and ie8.
    
    Apparently it's quite easy fix - just set iframe.src to any value. That way onunload will be triggered. This must be done we actually remove the iframe using parentNode.removeChild.
    
    This also seems to be working in opera.
---
 lib/dom.js                     | 5 ++++-
 tests/html/src/domtests.coffee | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/dom.js b/lib/dom.js
index 0b9efc8..988a872 100644
--- a/lib/dom.js
+++ b/lib/dom.js
@@ -190,8 +190,11 @@ utils.createIframe = function (iframe_url, error_callback) {
     var cleanup = function() {
         if (iframe) {
             unattach();
-            iframe.parentNode.removeChild(iframe);
+            // This is required, in order to force ie7 to fire the
+            // onunload event. Setting .src must happen before the
+            // removeChild step.
             iframe.src = "about:blank";
+            iframe.parentNode.removeChild(iframe);
             iframe = null;
             utils.detachEvent('unload', cleanup);
         }
diff --git a/tests/html/src/domtests.coffee b/tests/html/src/domtests.coffee
index b523cea..2b25f0c 100644
--- a/tests/html/src/domtests.coffee
+++ b/tests/html/src/domtests.coffee
@@ -12,7 +12,7 @@ newIframe = ->
     hook.iobj = u.createIframe('/iframe.html?a=' + Math.random() + '#' + hook.id, err)
     return hook
 
-if navigator.userAgent.indexOf('Konqueror') isnt -1 or $.browser.opera
+if navigator.userAgent.indexOf('Konqueror') isnt -1
     test "onunload [unsupported by client]", ->
         ok(true)
 else

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list