单独定义一个css , 其媒体类型设置为printLZ 给你写个例子看。<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<style type="text/css" media="print">
.print {
display: none;
}
</style>
</head><body><h3>Languages</h3>
<ul>
<li>
before
</li>
<li class="print">
Test
</li>
<li>
after
</li>
</ul></body>
</html>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<style type="text/css" media="print">
.print {
display: none;
}
</style>
</head><body><h3>Languages</h3>
<ul>
<li>
before
</li>
<li class="print">
Test
</li>
<li>
after
</li>
</ul></body>
</html>
function setupPage(){
var wsh;
wsh =new ActiveXObject("WScript.Shell");
wsh.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet explorer\\PageSetup\\header", "", "REG_SZ");
wsh.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet explorer\\PageSetup\\footer", "", "REG_SZ");
}
//----- 下面是打印控制语句 ----------
window.onbeforeprint=beforePrint;
window.onafterprint=afterPrint;
//打印之前隐藏不想打印出来的信息
function beforePrint()
{
setupPage();var pri2=document.getElementById("menuLayer");pri2.style.display='none';}
//打印之后将隐藏掉的信息再显示出来
function afterPrint()
{ var pri2=document.getElementById("menuLayer");pri2.style.display='';
}
</script>
LZ说的是,打印时候除去页眉页脚吧!