简体   繁体   English

执行打印后关闭弹出窗口

[英]Closing a popup window after performing print

I have a requirement tp popup a window display a pdf page, perform silent print and close the same. 我要求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();}" 

I used the above code to get the popup , on click of print I write this code to my page and the following to call a servlet to generate the pdf; 我使用上面的代码来获取弹出窗口,点击打印后,我将此代码写到页面上,然后使用下面的代码调用servlet生成pdf;

        FacesContext context = FacesContext.getCurrentInstance();
    HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
    HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
    RequestDispatcher dispatcher = request.getRequestDispatcher("/hisprintservlet");

My question is this, I have been able to bring up the window, perform silent print but no matter what I do the popup wont close. 我的问题是,我已经能够调出窗口,执行静音打印,但是无论我做什么弹出窗口都不会关闭。

I am using IE 11 and the project uses ADF 12c. 我正在使用IE 11,并且该项目使用ADF 12c。

Please help.. 请帮忙..

Checkout the docs on Popups here . 此处签出Popups上的文档。

function showPopup(event) { event.cancel(); 函数showPopup(event){event.cancel(); var source = event.getSource(); var source = event.getSource(); var popupid="popup"; var popupid =“ popup”; var popup = AdfPage.PAGE.findComponentByAbsoluteId(popupId); 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);
}

} }

function hidePopup(event) { event.cancel(); 函数hidePopup(event){event.cancel(); var source = event.getSource(); var source = event.getSource(); var popupId = source.getProperty("popupId"); var popupId = source.getProperty(“ popupId”); var isCanceled = source.getProperty("isCanceled"); var isCanceled = source.getProperty(“ isCanceled”);

var popup = AdfPage.PAGE.findComponentByAbsoluteId(popupId);

if (popup.isPopupVisible())
{                 
  if (isCanceled)
    popup.cancel();
  else
    popup.hide();
}

} ... ... Hello World! } ... ... 你好,世界!

... ... ……

I found a solution for this.. i added an iframe to my popup window. 我为此找到了解决方案。我在弹出窗口中添加了iframe。 In the body tag I added the followingg code to close .. 在body标签中,我添加了以下代码以关闭..

function test(win){if(win==null){alert('null');} else {setTimeout(function(win){this.close();},3000);}}

This works well in IE11 这在IE11中效果很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM