頁面的列印:
<a href='#' class='notprint' οnclick='pagesetup_null();self.print();'><img src=../images/printer.png border=0 title='列印' ></a>
不列印頁眉頁腳:
<script language="javascript">
var hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="//Software//Microsoft//Internet Explorer//PageSetup//"
//设置网页打印的页眉页脚为空
function pagesetup_null()
{
try{
var RegWsh = new ActiveXObject("WScript.Shell")
hkey_key="header"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")
hkey_key="footer"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")
}catch(e){}
}
</script>
某些元素不列印:(注意第二行的粉紅字)
<style>
@media print {
.notprint {
display:none;
}
}
@media screen {
.notprint {
display:inline;
cursor:hand;
}
}
</style>
參考來源:http://qbit.100steps.net/javascript/打印预览部分页面.htm(http://cache.baidu.com/c?word=javascript%2C%B2%BB%3B%B4%F2%D3%A1&url=http%3A//qbit%2E100steps%2Enet/javascript/%B4%F2%D3%A1%D4%A4%C0%C0%B2%BF%B7%D6%D2%B3%C3%E6%2Ehtm&b=0&a=3&user=baidu)