使用javascript自动关闭弹出窗口 [英] Automatically closing popup window using javascript

查看:80
本文介绍了使用javascript自动关闭弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

我要求关闭弹出窗口,我要求的场景是此页面parent.html包含否.现在,当我单击此sampleFile.pdf时,例如egsampleFile.pdf,sampleFile.doc等(服务器上的所有文件)的链接的链接应打开弹出窗口(工作正常)并在弹出窗口中显示pdf文件,但是当我单击sampleFile.doc,它应该在Microsoft Word中从客户端打开(工作正常),但问题是弹出窗口保持打开状态直到手动关闭,但是单击doc链接时应该关闭它,该如何使用javascript来完成?


在此先感谢
任何帮助将不胜感激
Saffuraj



I have requirement to close popup window, scenario of my requirement is this one page parent.html consist no. of link for e.g.sampleFile.pdf,sampleFile.doc,etc(all file on server) now when i click on this sampleFile.pdf it should open popup window(which is working fine)and display pdf file in popup window,but when i click sampleFile.doc it should open from client side in Microsoft Word(work fine) but problem is that Popup window remain open till close manually but it should get closed when click on doc link,how it is to be done using javascript ?


Thanks in Advance
any help would be appreciated
Saffuraj

推荐答案

假设您正在使用window.open,则需要维护打开的弹出窗口的集合.然后,在允许执行默认操作之前,在关闭所有打开的窗口的每个链接中添加一个客户端点击事件处理程序.
You would need to maintain a collection of the popup windows you open, assuming you are using window.open. Then add a client-side click event handler to each link that closes all of the open windows before allowing the default action to proceed.


这篇关于使用javascript自动关闭弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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