• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
nicesoft
博客园    首页    新随笔    联系   管理    订阅  订阅

web局部打印


<!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 runat="server">
    <title></title>
</head>
<script type="text/javascript">
    function PrintSubPage(ContentId) {
        var PrintWin = window.open('about:blank', 'Print');
        PrintWin.document.write('<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>' + document.getElementById(ContentId).innerHTML);

        //打印ContentId容器中的內容。
        PrintWin.document.all.WebBrowser.ExecWB(7, 1);
        PrintWin.close();
        /*
        WebBrowser.ExecWB(6,6)   直接打印
        WebBrowser.ExecWB(8,1)   页面设置
        WebBrowser.ExecWB(7,1)   打印预览*/  
    }
</script>
<body>
    <form id="form1" runat="server">
    2222222222不打印
    <div>
        <asp:Button ID="Button1" OnClientClick="PrintSubPage('div1');" runat="server" Style="left: 678px;
            position: relative; top: 96px" Text="Button" />111111111111111111111不打印
        <div id="div1" style="left: 0px; width: 521px; position: relative; top: 0px; height: 354px">
            asdfsadfsadfsdaf会打印</div>
    </div>
    </form>
</body>
</html>

posted @ 2011-12-01 11:50  nicesoft  阅读(286)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3