加载后打印弹出窗口

时间:2016-01-07 18:49:50

标签: javascript jquery

我花了超过5个小时,我正在尝试在弹出窗口中加载链接,加载后我想打印它。

所以我做的是以下

InputStream is = this.getClass().getResourceAsStream(String filePath);
Map<String, Object> requestContext = ((BindingProvider)client).getRequestContext();
PolicyBuilder builder = bus.getExtension(org.apache.cxf.ws.policy.PolicyBuilder.class);
try {
  Policy wsSecuritypolicy = builder.getPolicy(is);
  requestContext.put(PolicyConstants.POLICY_OVERRIDE, wsSecuritypolicy);
}
catch (Exception e) {
  throw new RuntimeException(e.toString());

}

requestContext.put(SecurityConstants.CALLBACK_HANDLER, MyCallBackClass.class.getName());

在onload中我已经尝试了<script src="http://code.jquery.com/jquery-latest.min.js"></script> <script> function printer(){ var link = 'file:///C:\\page0339.swf'; w = window.open(link, "_blank", "location=1,scrollbars=1,menuBar=1,width=600, height=400"); w.onload = function() { this.print(); this.close(); }; } $(document).ready(function () { $("#print").click(function () { printer(); }); }); </script> <input type ="button" id = "print" value = 'print' /> 消息并且它显示但是alert都没有被调用,我没有看到任何javascript错误。 那么如何在onload中调用print函数?

1 个答案:

答案 0 :(得分:0)

似乎在打开窗口后附加一个onload是错误的方法。而不是

w.onload = function() { 
                this.print();
                this.close();
            };

你试过这个吗?

w.print();
w.close();