关于打印时隐藏收缩问题,欢迎高手给我提供解决思路!
先看我的程序吧:
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000" onbeforeprint="hideDiv(div1);" onafterprint="showDiv(div1);" >
<form name="form1" >
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="4" height="34">
<div id="div1" style="width:100%;height:auto;overflow:hidden;visibility:visiable" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="3%" height="31">a</td>
<td width="27%" height="31">
<input type="text" name="id">
</td>
<td width="23%" height="31">b</td>
<td width="47%" height="31">
<input type="text" name="name">
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="button" name="show" value="show" onClick="showDiv(div1);">
</td>
<td colspan="2" align="center" width="56%">
<input type="button" name="hide" value="hide" onClick="hideDiv(div1);">
</td>
</tr>
</table>
</form>
</body>
</html>
<script language="javascript">
function showDiv(obj)
{
obj.style.visibility = "visible";
obj.className="expanded";
}
function hideDiv(obj)
{
obj.style.visibility = "hidden";
obj.className="collapsed";
}
</script>
以上程序实现了把div之间的表打印(打印预览)时隐藏,但是没有把隐藏的部分给清除掉,打印是还占有空间,很是难看,请高手们帮一下忙,解决一下!