关于页面打印的问题

hamburgsjn 2003-02-22 10:17:19
我页面已经定义好宽度和高度,恰好打印到一张A4纸上,但不论通过IE的菜单还是JAVASCRIPT 的window.print()打印都出现页面设置打印机选择对话框,
1请问如何通过JAVASCRIPT控制打印不出现该对话框
2请问如何通过JAVASCRIPT控制打印时去掉页眉和页脚
谢谢

20分*2
...全文
26 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
purecat 2003-03-06
  • 打赏
  • 举报
回复
给个例子,别人的
<HTML><HEAD>
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>
<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){}
}
//设置网页打印的页眉页脚为默认值
function pagesetup_default(){
try{
var RegWsh = new ActiveXObject("WScript.Shell")
hkey_key="header"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P")
hkey_key="footer"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d")
}catch(e){}
}
function to_print()
{
pagesetup_null();
document.all.to_print.style.display="none";
document.all.to_review.style.display="none";
document.all.WebBrowser.ExecWB(6,6);
document.all.to_print.style.display="";
document.all.to_review.style.display="";
}
</script>
</HEAD>

<BODY><br/><br/><br/><br/><br/><br/><p align=center>
<input type="button" name="to_print" value="打印" onclick="to_print()">
<input type="button" name="to_review" value="恢复页码" onclick="pagesetup_default()"><br/>
</p></BODY></HTML>
wanghr100 2003-02-23
  • 打赏
  • 举报
回复
WEB打印的相关技术分析总结
http://expert.csdn.net/Expert/topic/1428/1428024.xml?temp=.6602747
zxhong 2003-02-22
  • 打赏
  • 举报
回复
1,http://expert.csdn.net/Expert/TopicView2.asp?id=973599&datebasetype=now
2,http://expert.csdn.net/Expert/TopicView2.asp?id=1294743&datebasetype=now

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧