[Commits] r1606 - sandbox/ahocevar/playground/ux/Printing/ux/data

commits at geoext.org commits at geoext.org
Wed Dec 23 17:26:05 CET 2009


Author: ahocevar
Date: 2009-12-23 17:26:05 +0100 (Wed, 23 Dec 2009)
New Revision: 1606

Modified:
   sandbox/ahocevar/playground/ux/Printing/ux/data/PrintProvider.js
Log:
make pdf download work in all browsers

Modified: sandbox/ahocevar/playground/ux/Printing/ux/data/PrintProvider.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/data/PrintProvider.js	2009-12-23 13:49:48 UTC (rev 1605)
+++ sandbox/ahocevar/playground/ux/Printing/ux/data/PrintProvider.js	2009-12-23 16:26:05 UTC (rev 1606)
@@ -311,7 +311,19 @@
                 url: this.capabilities.createURL,
                 jsonData: jsonData,
                 success: function(response) {
-                    window.open(Ext.decode(response.responseText).getURL);
+                    // In IE, using a Content-disposition: attachment header
+                    // may make it hard or impossible to download the pdf due
+                    // to security settings. So we'll display the pdf inline.
+                    var url = Ext.decode(response.responseText).getURL +
+                        (Ext.isIE ? "?inline=true" : "");
+                    if(Ext.isOpera || Ext.isIE) {
+                        // Make sure that Opera and IE don't replace the
+                        // content tab with the pdf
+                        window.open(url);
+                    } else {
+                        // This avoids popup blockers for all other browers
+                        window.location.href = url;                        
+                    } 
                 }
             });
         }



More information about the Commits mailing list