VBScript实现IE浏览器直接打印功能

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <title>打印测试</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <!--media=print 这个属性可以在打印时有效-->
    <style media="print">
        .Noprint
        {
            display: none;
        }
        .PageNext
        {
            page-break-after: always;
        }
    </style>
    <style>
        .tdp
        {
            border-bottom: 1 solid #000000;
            border-left: 1 solid #000000;
            border-right: 0 solid #ffffff;
            border-top: 0 solid #ffffff;
        }
        .tabp
        {
            border-color: #000000 #000000 #000000 #000000;
            border-style: solid;
            border-top-width: 2px;
            border-right-width: 2px;
            border-bottom-width: 1px;
            border-left-width: 1px;
        }
        .NOPRINT
        {
            font-family: "宋体";
            font-size: 9pt;
        }
    </style>


<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT> 
<SCRIPT LANGUAGE="VBScript"> 
Sub window_onunload 
On Error Resume Next 
Set WB = nothing 
End Sub 
Sub vbPrintPage ( x , y , z ) 
OLECMDID_PRINT = 6 
OLECMDEXECOPT_DODEFAULT = 0 
OLECMDEXECOPT_PROMPTUSER = 1 
OLECMDEXECOPT_DONTPROMPTUSER = 2 
On Error Resume Next 
WB.ExecWB x, y, z, 0 
End Sub 
</SCRIPT> 


</head>
<body>
    <center class="Noprint">
        <p>
            <object id="WebBrowser" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0"
                width="0">
            </object>
  
<INPUT TYPE="BUTTON" VALUE="Print" ONCLICK="vbPrintPage 6, 2, 3"><BR> 
            <INPUT TYPE="BUTTON" VALUE="Preview" ONCLICK="vbPrintPage 7, 1, 0"><BR> 
            <INPUT TYPE="BUTTON" VALUE="Page Setup" ONCLICK="vbPrintPage 8, 1, 0"><BR> 
       </p>
    </center>
    <table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="tabp">
        <tr>
            <td colspan="3" class="tdp">
                第1页
            </td>
        </tr>
        <tr>
            <td width="29%" class="tdp">
                 
            </td>
            <td width="28%" class="tdp">
                 
            </td>
            <td width="43%" class="tdp">
                 
            </td>
        </tr>
        <tr>
            <td colspan="3" class="tdp">
                 
            </td>
        </tr>
        <tr>
            <td colspan="3" class="tdp">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td width="50%" class="tdp">
                            <p>
                                这样的报表</p>
                            <p>
                                对一般的要求就够了。</p>
                        </td>
                        <td>
                             
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <!--分页-->
    <div class="PageNext">
    </div>
    <table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="tabp">
        <tr>
            <td class="tdp">
                第2页
            </td>
        </tr>
        <tr>
            <td class="tdp">
                看到分页了吧
            </td>
        </tr>
        <tr>
            <td class="tdp">
                 
            </td>
        </tr>
        <tr>
            <td class="tdp">
                 
            </td>
        </tr>
        <tr>
            <td class="tdp">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td width="50%" class="tdp">
                            <p>
                                这样的报表</p>
                            <p>
                                对一般的要求就够了。</p>
                        </td>
                        <td>
                             
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <!--分页-->
    <div class="PageNext">
    </div>
    <table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="tabp">
        <tr>
            <td class="tdp">
                第3页
            </td>
        </tr>
        <tr>
            <td class="tdp">
                看到分页了吧
            </td>
        </tr>
        <tr>
            <td class="tdp">
                 
            </td>
        </tr>
        <tr>
            <td class="tdp">
                 
            </td>
        </tr>
        <tr>
            <td class="tdp">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td width="50%" class="tdp">
                            <p>
                                这样的报表</p>
                            <p>
                                对一般的要求就够了。</p>
                        </td>
                        <td>
                             
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
<div class="PageNext">
    </div>
<table  class="tabp">
<tr>
<td>test</td>
</tr>
</table>
</body>
</html>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
A: 首先,需要了解ie浏览器的安全选项有哪些以及对应的注册表键值。参考微软官方文档: https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms537170(v=vs.85)?redirectedfrom=MSDN 然后根据文档中的说明,可以使用Windows脚本语言(如VBScript)来修改注册表键值,以实现启用ie浏览器的安全选项。 以下是一个示例脚本: ```vbscript ' 恢复ie浏览器的默认安全选项 ' 注:需要管理员权限运行 Const HKEY_CURRENT_USER = &H80000001 'DIM RegLocation Dim WshShell, fso Set WshShell = CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") If WScript.Arguments.Count >= 1 Then RegLocation = WScript.Arguments.Item(0) Else RegLocation = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones" End If Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(fso.GetParentFolderName(wscript.ScriptFullName)) Set objFolderItem = objFolder.ParseName(fso.GetFileName(wscript.ScriptFullName)) If objFolderItem.IsFolder Then WScript.Echo "Please double-click the script file to launch it." WScript.Quit End If ' 修改每个区域的安全选项 For i = 0 To 4 EnableIEOption(i, RegLocation) Next WScript.Echo "IE security options have been enabled for all zones." Function EnableIEOption(zone, RegLoc) ' 定义注册表路径和键名 Dim RegPath RegPath = RegLoc & "\" & zone Dim KeyName Select Case zone Case 0 KeyName = "2500" Case 1 KeyName = "2501" Case 2 KeyName = "2502" Case 3 KeyName = "2503" Case 4 KeyName = "2504" Case Else Exit Function End Select ' 设置对应键值的数值为 0 WshShell.RegWrite "HKEY_CURRENT_USER\" & RegPath & "\" & KeyName, 0, "REG_DWORD" End Function ``` 通过双击运行以上脚本,即可将ie浏览器的安全选项全部启用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值