diff --git a/WebContent/printing/OSRM.Printing.js b/WebContent/printing/OSRM.Printing.js index 42d84c5f3..4c221ff58 100644 --- a/WebContent/printing/OSRM.Printing.js +++ b/WebContent/printing/OSRM.Printing.js @@ -166,9 +166,7 @@ print: function() { // generate a new window and wait till it has finished loading OSRM.G.printwindow = window.open("printing/printing.html","","width=540,height=500,left=100,top=100,dependent=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes"); - //OSRM.Browser.onLoadHandler( OSRM.Printing.printwindowLoaded, OSRM.G.printwindow ); - //OSRM.Browser.onLoadHandler( OSRM.Printing.printwindowLoaded, OSRM.G.printwindow.document ); - setTimeout( OSRM.Printing.printwindowLoaded, 500); + OSRM.Browser.onLoadHandler( OSRM.Printing.printwindowLoaded, OSRM.G.printwindow ); }, diff --git a/WebContent/utils/OSRM.browsers.js b/WebContent/utils/OSRM.browsers.js index 923ac2b0a..9d4d7ec8f 100644 --- a/WebContent/utils/OSRM.browsers.js +++ b/WebContent/utils/OSRM.browsers.js @@ -46,17 +46,18 @@ OSRM.Browser.getElementsByClassName = function( node, classname ) { }; // call a function when DOM has finished loading and remove event handler (optionally pass a different window object) -OSRM.Browser.onLoadHandler = function( function_pointer, the_document ) { - the_document = the_document || document; // default document +OSRM.Browser.onLoadHandler = function( function_pointer, the_window ) { + the_window = the_window || window; // default document + var the_document = the_window.document; - if(the_document.addEventListener) { // FF, CH, IE9+ + if(the_window.addEventListener) { // FF, CH, IE9+ var temp_function = function() { - the_document.removeEventListener("DOMContentLoaded", arguments.callee, false); + the_window.removeEventListener("DOMContentLoaded", arguments.callee, false); function_pointer.call(); }; - the_document.addEventListener("DOMContentLoaded", temp_function, false); + the_window.addEventListener("DOMContentLoaded", temp_function, false); } - + else if(the_document.attachEvent) { // IE8- var temp_function = function() { if ( the_document.readyState === "interactive" || the_document.readyState === "complete" ) {