[英]Closing a popup window after performing print
我要求tp弹出窗口,显示pdf页面,执行静默打印并关闭它。
String s =
"var win = window.open('PrintPopUp.jsf','_blank',\"height=300,width=200,scrollbars=no," +
"status=no, resizable=no, screenx=0, screeny=0\");" +
"win.onclick= function(){ win.close();}"
我使用上面的代码来获取弹出窗口,点击打印后,我将此代码写到页面上,然后使用下面的代码调用servlet生成pdf;
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
RequestDispatcher dispatcher = request.getRequestDispatcher("/hisprintservlet");
我的问题是,我已经能够调出窗口,执行静音打印,但是无论我做什么弹出窗口都不会关闭。
我正在使用IE 11,并且该项目使用ADF 12c。
请帮忙..
在此处签出Popups上的文档。
函数showPopup(event){event.cancel(); var source = event.getSource(); var popupid =“ popup”; var popup = AdfPage.PAGE.findComponentByAbsoluteId(popupId);
if (!popup.isPopupVisible())
{
var hints = {};
hints[AdfRichPopup.HINT_LAUNCH_ID] = source.getClientId();
hints[AdfRichPopup.HINT_ALIGN_ID] = source.getClientId();
hints[AdfRichPopup.HINT_ALIGN] = AdfRichPopup.ALIGN_AFTER_START;
popup.show(hints);
}
}
函数hidePopup(event){event.cancel(); var source = event.getSource(); var popupId = source.getProperty(“ popupId”); var isCanceled = source.getProperty(“ isCanceled”);
var popup = AdfPage.PAGE.findComponentByAbsoluteId(popupId);
if (popup.isPopupVisible())
{
if (isCanceled)
popup.cancel();
else
popup.hide();
}
} ... ... 你好,世界!
……
我为此找到了解决方案。我在弹出窗口中添加了iframe。 在body标签中,我添加了以下代码以关闭..
function test(win){if(win==null){alert('null');} else {setTimeout(function(win){this.close();},3000);}}
这在IE11中效果很好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.