本文介绍了在网页中打印不同的部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
推荐答案
<%@ 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>
这篇关于在网页中打印不同的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!