Jump to content

Strange occurrence with window.open and PDF's


ShadowMage

Recommended Posts

Hey guys, bizarre occurrence here.I have a page that I open in a new window with javascript. This page uses the FPDF class to generate a PDF document, which can then be saved to a file or displayed directly in the browser.Everything works just peachy in FF, but in IE I get nothing but a blank screen. It used to work, I know it did because I have been testing in FF and IE throughout this entire project... :)Anyway, it doesn't work if I use window.open("url") to open the page, but <a href='url' target='_blank'>page</a> works perfectly. :) It also works just fine if I export the PDF to a file first and then redirect (either PHP or javascript) to the PDF document. But for some reason, it just will not work when I use window.open! :)Anyone have any ideas what might be going on? I don't think it's a javascript or PHP issue, I think it's a browser issue. That's why I posted in General.

Link to comment
Share on other sites

It may be helpful to use a packet analyzer to compare the requests and responses when you use window.open versus another method. Look for changed or missing headers and things like that.
Any recommendations on good analyzers for IE? I can't seem to find any such thing in IE's developer tools. Does Debugbar have one? I used to have that installed but I removed it because IE's developer tools seem better.EDIT:DebugBar does indeed contain header information. Unfortunately, it was inconclusive. The headers matched exactly except that the link also sent a referrer header. Interestingly, the link window (the one that works) is rendered using quirks mode while the window.open method renders in standards mode. That may have something to do with the fact that the link displays an actual PDF document instead of a blank page.Ugh, I hate IE... :)Any other ideas on what might be going on? Seems like all the headers are being sent properly. Any more information you might need, just ask.
Link to comment
Share on other sites

Are the headers for the requests and responses the same regardless of how the window is opened?
Yes. If I use window.open to launch the window or if I use an anchor with target='_blank' I get the exact same headers. (with the exception of the referrer from the anchor tag, otherwise everything else matches exactly)I've discovered that using location.assign() allows it to display the PDF too. If I open the window with window.open and have just a dummy page with no content and in window.onload I use location.assign() to redirect to my PHP script it displays just fine.I am really baffled by the behavior with this... :)
Link to comment
Share on other sites

It's hard to debug things like this, especially remotely. When I run into weird problems in IE, like why can't a Flash movie inside a frame launch a link to an Office document if the computer has Office installed and either IE7 or IE8, but not IE6, it normally takes me several hours of testing the various factors involved and researching before I can even identify the specific problem, and then some more time to figure out a workaround. IE is just special that way, that's why it's so much fun to work with. I ended up with a similar fix, I launched it in a window that redirected. I had another problem with IE and Flash where a Flash movie was trying to post something, once again inside of a frame, and it wouldn't send a content-type header with the request, so it wasn't recognized as a post request. Fun times.

Link to comment
Share on other sites

Does the class output a content-type header? Are you doing so? (You probably thought of this . . .)
I assume so. I didn't really look, but the appropriate header is being sent (application/pdf)
It's hard to debug things like this, especially remotely. When I run into weird problems in IE, like why can't a Flash movie inside a frame launch a link to an Office document if the computer has Office installed and either IE7 or IE8, but not IE6, it normally takes me several hours of testing the various factors involved and researching before I can even identify the specific problem, and then some more time to figure out a workaround. IE is just special that way, that's why it's so much fun to work with. I ended up with a similar fix, I launched it in a window that redirected. I had another problem with IE and Flash where a Flash movie was trying to post something, once again inside of a frame, and it wouldn't send a content-type header with the request, so it wasn't recognized as a post request. Fun times.
Yeah, it is hard to debug this stuff remotely. I just thought I'd ask in hopes that somebody else has come across this problem and knew how to fix it. :) Thank you for your efforts.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...