IE won't load PDF in a window created with window.open

Posted by Dean on Stack Overflow See other posts from Stack Overflow or by Dean
Published on 2010-04-27T19:27:52Z Indexed on 2010/04/27 20:03 UTC
Read the original article Hit count: 453

Filed under:
|
|
|
|

Here's the problem, which only occurs in Internet Explorer (IE). I have a page that has links to several different types of files. Links from these files execute a Javascript function that opens a new window and loads the specific file. This works great, unless the file I need to open in the new window is a PDF in which case the window is blank, even though the URL is in the address field. Refreshing that window using F5 doesn't help. However, if I put the cursor in the address field and press <enter> the PDF loads right up.

This problem only occurs in IE. I have seen it in IE 7 and 8 and am using Adobe Acrobat Reader 9. In Firefox (PC and Mac) everything works perfectly. In Chrome (Mac), the PDF is downloaded. In Safari (Mac) it works. In Opera (Mac) it prompts me to open or save. Basically, everything probably works fine, except for IE.

I have searched for similar problems and have seen some posts where it was suggested to adjust some of the Internet Options on IE. I have tried this but it doesn't help, and the problem wasn't exactly the same anyway.

Here's the Javascript function I use to open the new window.

function newwin(url,w,h) {
   win = window.open(url,"temp","width="+w+",height="+h+",menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=auto,resizable=yes");
   win.focus();
}

You can see that I pass in the URL as well as the height, h, and width, w, of the window. I've used a function like this for years and as far as I know have never had a problem.

I call the newwin() function using this.

<a href="javascript:newwin('/path/document.pdf',400,300)">document.pdf</a>

(Yes, I know there are other, better ways than using inline JS, and I've even tried some of them because I've run out of things to try, but nothing works.)

So, if anyone has an idea as to what might be causing this problem, I'd love to hear it.

© Stack Overflow or respective owner

Related posts about ie

Related posts about JavaScript