IE不会在使用window.open创建的窗口中加载PDF [英] IE won't load PDF in a window created with window.open

查看:562
本文介绍了IE不会在使用window.open创建的窗口中加载PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是问题,仅在Internet Explorer(IE)中发生.我有一个页面,其中包含指向几种不同类型文件的链接.这些文件中的链接执行Javascript函数,该函数会打开一个新窗口并加载特定文件.这很有用,除非我需要在新窗口中打开的文件是PDF,在这种情况下,即使URL在地址字段中,窗口也为空白.使用F5刷新该窗口无济于事.但是,如果我将光标放在地址字段中并按<enter>,则PDF会立即加载.

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.

仅在IE中会出现此问题.我已经在IE 7和8中看到它,并且正在使用Adobe Acrobat Reader9.在 Firefox (PC和Mac)中,一切正常.在 Chrome (Mac)中,下载了PDF.在 Safari (苹果机)中,它可以工作.在 Opera (Mac)中,它提示我打开或保存.基本上,除了IE之外,其他所有东西都可以正常工作.

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.

我已经搜索了类似的问题,并且看到了一些帖子,建议在其中调整IE上的某些Internet选项.我已经尝试过了,但这无济于事,问题还是不完全相同.

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.

这是我用来打开新窗口的Javascript函数.

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();
}

您可以看到我输入了URL以及窗口的高度h和宽度w.据我所知,我使用这样的函数已经有很多年了.

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.

我使用此调用newwin()函数.

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

(是的,我知道比使用内联JS还有其他更好的方法,我什至尝试了其中的一些方法,因为我已经花了很多时间尝试了,但是没有用.)

(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.

推荐答案

尝试:

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

这篇关于IE不会在使用window.open创建的窗口中加载PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆