如何使用javascript关闭IE中的pdf选项卡 [英] How can I use javascript to close a pdf tab in IE

查看:125
本文介绍了如何使用javascript关闭IE中的pdf选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IE 11中,我在使用非标准html内容关闭标签时遇到问题,例如pdf,swf。

In IE 11, I have a problem to close tab with non-standard html content, such as pdf, swf.

场景是:在我的主页上,我使用javascript打开pdf标签(已安装pdf扩展名):

The scenario is: on my homepage, I use javascript to open a pdf tab (pdf extensions is installed):

var myWin = window.open("https://localhost/test/test.pdf", "_blank")

然后我需要关闭此标签,我认为这样会很容易:

Then I need to close this tab, I thought it would be easy as before:

myWin.close()

但这不起作用,对象myWin很奇怪,myWin。封闭总是如此,即使我没有关闭它。

But this does not work, the object myWin is weird, myWin.closed is always true, even though I did not close it.

并且无法访问myWin.location.href,IE 11将抛出"权限被拒绝"。错误。 

and myWin.location.href can not be accessed, IE 11 will throw "Permission denied" error. 

我可以关闭普通html内容的标签。但是当我尝试包含pdf或swf的标签时,我遇到了上述问题。

I can close the tabs of normal html content. But When I try tabs containing pdf or swf, I have the above problem.

那么......如何关闭那些pdf / swf标签....有什么建议吗?

So...How to close those pdf/swf tabs....Any suggestions?

提前致谢。

推荐答案

Hi Thusimon,

Hi thusimon,

感谢您在这里发帖。

对于您的情况,我建议您使用
closeDoc
在myWin.close之前查看它是否有效。

For your case, I suggest you to use closeDoc before myWin.close to see if it works.

最好的问候,

Sera Yu


这篇关于如何使用javascript关闭IE中的pdf选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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