mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-105: Merge iframe cleanup fix.
This commit is contained in:
@@ -43,6 +43,17 @@ angular.module('rest').factory('tunnelService', ['$injector',
|
|||||||
*/
|
*/
|
||||||
var document = $window.document;
|
var document = $window.document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of milliseconds to wait after a stream download has completed
|
||||||
|
* before cleaning up related DOM resources, if the browser does not
|
||||||
|
* otherwise notify us that cleanup is safe.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @constant
|
||||||
|
* @type Number
|
||||||
|
*/
|
||||||
|
var DOWNLOAD_CLEANUP_WAIT = 5000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a request to the REST API to get the list of all tunnels
|
* Makes a request to the REST API to get the list of all tunnels
|
||||||
* associated with in-progress connections, returning a promise that
|
* associated with in-progress connections, returning a promise that
|
||||||
@@ -189,6 +200,7 @@ angular.module('rest').factory('tunnelService', ['$injector',
|
|||||||
// Create temporary hidden iframe to facilitate download
|
// Create temporary hidden iframe to facilitate download
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement('iframe');
|
||||||
iframe.style.position = 'fixed';
|
iframe.style.position = 'fixed';
|
||||||
|
iframe.style.border = 'none';
|
||||||
iframe.style.width = '1px';
|
iframe.style.width = '1px';
|
||||||
iframe.style.height = '1px';
|
iframe.style.height = '1px';
|
||||||
iframe.style.left = '-1px';
|
iframe.style.left = '-1px';
|
||||||
@@ -197,11 +209,20 @@ angular.module('rest').factory('tunnelService', ['$injector',
|
|||||||
// The iframe MUST be part of the DOM for the download to occur
|
// The iframe MUST be part of the DOM for the download to occur
|
||||||
document.body.appendChild(iframe);
|
document.body.appendChild(iframe);
|
||||||
|
|
||||||
// Automatically remove iframe from DOM when download completes
|
// Automatically remove iframe from DOM when download completes, if
|
||||||
stream.onend = function downloadComplete() {
|
// browser supports tracking of iframe downloads via the "load" event
|
||||||
|
iframe.onload = function downloadComplete() {
|
||||||
document.body.removeChild(iframe);
|
document.body.removeChild(iframe);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Automatically remove iframe from DOM a few seconds after the stream
|
||||||
|
// ends, in the browser does NOT fire the "load" event for downloads
|
||||||
|
stream.onend = function downloadComplete() {
|
||||||
|
$window.setTimeout(function cleanupIframe() {
|
||||||
|
document.body.removeChild(iframe);
|
||||||
|
}, DOWNLOAD_CLEANUP_WAIT);
|
||||||
|
};
|
||||||
|
|
||||||
// Begin download
|
// Begin download
|
||||||
iframe.src = url;
|
iframe.src = url;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user