绕过IE9中的Printdialog [英] Bypass Printdialog in IE9

查看:74
本文介绍了绕过IE9中的Printdialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 我正在寻找一种绕过IE 9中的printdialog的方法.我现在有一些方法可以使用ie 7/8,但是它们在ie9上对我不起作用

hy i am looking for a way to bypass the printdialog in IE 9. I now that there are some ways for ie 7/8 but they dont work for me at ie9

有人可以给我一个提示吗?

can someone please give me a hint?

打招呼

推荐答案

成功的关键组合似乎是在onclick事件中调用正确的函数(例如,Print()而不是window.print()).在IE9(以及其他任何版本的IE)中配置了正确的安全设置.

The key combination for success here appears to be calling the right function in the onclick event (e.g. Print() rather than window.print() ), as well as having the proper security settings configured in IE9 (as well as any other version of IE).

但是,如果通过受信任的安全HTTPS连接(具有受信任的SSL证书而不是自签名的访问)访问带有print-dialog-bypass ActiveX控件的页面,则似乎不需要配置安全设置. SSL证书).

However, it appears security settings may not be required to be configured if the page with print-dialog-bypass ActiveX control is being accessed via a trusted secure HTTPS connection (one with a trusted SSL cert, rather than a self-signed SSL cert).

如果通过本地文件路径访问页面,则根本不起作用.如果您打算针对无法控制其浏览器的用户,请牢记这两个方面,但是,如果确实是这种情况,则最好使用另一种方法,最好是使用诸如 Java或要求用户安装本机OS软件,例如使用优惠券打印网站.

It does not work at all if the page is accessed via local file path. Keep both of those in mind if you intend to target users whose browsers you cannot control, however if such a situation is indeed your case, you're probably best using another approach altogether, using technology such as Java or require users to install native OS software, such as the coupon printing websites employ.

在任何情况下,使用适当的安全设置,IE9都应允许您使用以下代码绕过打印对话框弹出窗口:

In any case, with the appropriate security settings, IE9 should allow you to bypass the print dialog popup window with the following code:

<!DOCTYPE html>
<html>
<head>
    <title>Print Test</title>
    <script language="VBScript">
        sub Print()
            OLECMDID_PRINT = 6
            OLECMDEXECOPT_DONTPROMPTUSER = 2
            OLECMDEXECOPT_PROMPTUSER = 1
            call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
        End Sub
        document.write "<object id='WB' width='0' height='0' classid='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"
    </script>
</head>
<body>
    <object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"> </object>
    <a href="#" onclick="Print()">Click Here to Print</a>
</body>
</html>

这个确切的代码在IE7,IE8和IE9中对我有用.我还没有机会使用IE10,但是它也可以在那儿工作.如果拥有IE10的任何人都可以进行测试,请进行报告.为了获得最佳结果,请记住从托管源(最好是受信任的HTTPS源)而不是在本地计算机上运行它.

This exact code worked for me in IE7, IE8 and IE9. I haven't yet had a chance to IE10 yet, but it might work there too. If anyone with IE10 can test, do report back. For best results, remember to run it from a hosted source, preferably a trusted HTTPS source, rather than on your local machine.

这是我必须在IE9中配置的设置,才能使上面的代码起作用.同样,它仅在从网络提供页面时才起作用.它的工作少了一些麻烦.如果我尝试直接从本地计算机加载相同的HTML文件,即使配置了相同的安全设置,该文件也无法正常工作.

Here are the settings I had to configure in IE9 to get the above code to work. Again, it only worked when the page was being served from the web. It worked with less nagging . If I tried to load the same HTML file directly from my local machine, it did NOT work, even with the same security settings configured.

粉色突出显示仅表示所配置的此类设置不安全.注意:您也可以选择提示",该提示比较麻烦,但被认为有些安全.

Pink highlighting simply denotes that such settings as configured are insecure. Note: you can also choose 'prompt' which is more nagging, but considered somewhat secure.

这篇关于绕过IE9中的Printdialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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