查看: 1232|回复: 8
|
在IE(browser)print时,要怎样才能删掉header和footer?
[复制链接]
|
|
VS 2005, ASP.net
我知道我们可以manually在自己的IE setting 里设定不要print header和footer,
但在做web app时,我们不能确定client PC 的IE setting, 所以请问各位大大有什么方法可以programmatically 来删掉header和footer呢?
(就好像我们print ebanking 的statement 那样,header和footer 那些URL 是看不到的)
感激不尽!! |
|
|
|
|
|
|
|
发表于 5-12-2006 11:27 PM
|
显示全部楼层
runtime create pdf file 或許比較容易 |
|
|
|
|
|
|
|
发表于 6-12-2006 02:41 AM
|
显示全部楼层
用 javascript copy DivContent 的 innerHtml
<html>
<title></title>
<body>
Header Header Header
<div id="DivContent">
content content content
</div>
Footer Footer Footer
</body>
</html> |
|
|
|
|
|
|
|

楼主 |
发表于 6-12-2006 08:51 AM
|
显示全部楼层
原帖由 hkloke2000 于 6-12-2006 02:41 AM 发表
用 javascript copy DivContent 的 innerHtml
<html>
<title></title>
<body>
Header Header Header
<div id="DivContent">
content content content
< ...
噢。。。okok...
我应该知道怎么做了。。
谢谢。。。 |
|
|
|
|
|
|
|
发表于 6-12-2006 11:58 PM
|
显示全部楼层
原帖由 hkloke2000 于 6-12-2006 02:41 AM 发表
用 javascript copy DivContent 的 innerHtml
<html>
<title></title>
<body>
Header Header Header
<div id="DivContent">
content content content
< ...
我有点不明白哦
难道叫js把它copy 出来 |
|
|
|
|
|
|
|
发表于 7-12-2006 12:07 PM
|
显示全部楼层
原帖由 红发 于 6-12-2006 11:58 PM 发表
我有点不明白哦
难道叫js把它copy 出来
1) copy 去新Windows
2) copy 出来替换现有的 HTML 内容 |
|
|
|
|
|
|
|

楼主 |
发表于 7-12-2006 05:22 PM
|
显示全部楼层
原帖由 红发 于 6-12-2006 11:58 PM 发表
我有点不明白哦
难道叫js把它copy 出来
红发老弟,
我的做法比较简单不用copy来copy去,只需要在header里加上:
<style type="text/css">
@media print{
body{ background-color:#FFFFFF; background-image:none; color:#000000 }
#contentarea{ width:100%;}
}
</style>
------------------------------------------------------
然后,在你的web page 里加上:
<div id="contentarea">你web page的内容</div>
------------------------------------------------------
当print的时候,它只会print在“contentarea” div 内的东西罢了。。。
[ 本帖最后由 chinjw 于 7-12-2006 05:26 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 7-12-2006 09:20 PM
|
显示全部楼层
原帖由 chinjw 于 7-12-2006 05:22 PM 发表
红发老弟,
我的做法比较简单不用copy来copy去,只需要在header里加上:
<style type="text/css">
@media print{
body{ background-color:#FFFFFF; background-image:none; color: ...
哦,刚刚test看了
但是我按print preview时,还是会看到header的哦
难道要我真真print的时候才看不到????
那我明天用company的printed看看 |
|
|
|
|
|
|
|
发表于 7-12-2006 10:35 PM
|
显示全部楼层
<script language="javascript">
function OpenPrinterFriendlyPage()
{
var WindowSetting="toolbar=yes,location=no,directories=yes,menubar=yes,";
WindowSetting+="scrollbars=yes,width=650, height=600, left=100, top=25";
var HtmlContent = document.getElementById( "DivContent" ).innerHTML;
var printWindow=window.open("","",WindowSetting);
printWindow.document.open();
printWindow.document.write('<html><head><title>Title</title>');
printWindow.document.write('</head><body onLoad="self.print()"><center>');
printWindow.document.write(HtmlContent);
printWindow.document.write('</center></body></html>');
printWindow.document.close();
printWindow.focus();
}
</script>
[ 本帖最后由 hkloke2000 于 7-12-2006 10:37 PM 编辑 ] |
|
|
|
|
|
|
| |
本周最热论坛帖子
|