在网页中打印不同的部分 [英] Print different parts in web page

查看:88
本文介绍了在网页中打印不同的部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

推荐答案

将以下代码保存在html文件中并进行测试..

它的工作完美!!

Save below code in html file and test..

Its Work perfect!!

<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"

    Inherits="_Default" %>

<html>
<head>
    <style type="text/css">
        #dv1, #dv2
        {
            font-size: 20px;
        }
    </style>
    <style media="print">
        .hidePrint
        {
            display: none;
        }
    </style>
    <script type="text/javascript" language="javascript">
        function fnSetStyle(Obj) {
            if (Obj == 1) {
                document.getElementById('dv1').className = '';
                document.getElementById('dv2').className = 'hidePrint';
            }
            else {
                document.getElementById('dv2').className = '';
                document.getElementById('dv1').className = 'hidePrint';
            }
        }
    </script>
    <title></title>
</head>
<body>
    <div id="dv1">
Portion 1: Place one portion here
    </div>
    <div id="dv2">
Portion 2: and another here..
    </div>
Common portion: and click on Div1 to print first portion and click on Div2 to print another portion<br />
    <input type="button" value="Div1" onclick="javascript:fnSetStyle(1);window.print();" />
    <input type="button" value="Div2" onclick="javascript:fnSetStyle(2);window.print();" />
</body>
</html>


这篇关于在网页中打印不同的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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