关于打印 javascript如何实现 横向打印?不打印页眉页脚,只打印页面中的一部分。感激不尽 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function PreviewReferralPrint() { bdhtml=window.document.body.innerHTML; sprnstr="<!--startprint-->"; eprnstr="<!--endprint-->"; prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17); prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); window.document.body.innerHTML=prnhtml; window.print(); window.parent.returnValue='0';window.parent.close(); }<!--startprint-->把要打印的HTML写在这里<!--endprint--> 用css 的media可指定列印內容 横向打印,你可以改一下打印设置啊,不过用javascript好像无法修改横向打印,不过可能和浏览器版本、操作系统有关,我的反正不行,你可以试试看,你修改注册表的“HKEY_CURRENT_USER->SoftWare->Microsoft->Internet Explorer->PageSetup”中的orientation项,此项就是控制打印的方向的,值可能有1和2之分,你可以改一下试试看。 avascript 设置不了呀晕 过了这么久你才回~~~服了~~!我现在正在做一个ActiveX控件,用于解决横向打印问题~~~~也就是通过ActiveX控件来设置打印的参数。 <HTML><HEAD><TITLE>web打印去掉页眉页脚,以及不想打印出的页面元素</TITLE><META http-equiv=Content-Type content="text/html; charset=gb2312"><SCRIPT language=javascript>function printpr() //预览函数{document.all("qingkongyema").click();//打印之前去掉页眉,页脚document.all("dayinDiv").style.display="none"; //打印之前先隐藏不想打印输出的元素(此例中隐藏"打印"和"打印预览"两个按钮)var OLECMDID = 7;var PROMPT = 1; var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';document.body.insertAdjacentHTML('beforeEnd', WebBrowser); WebBrowser1.ExecWB(OLECMDID, PROMPT);WebBrowser1.outerHTML = "";document.all("dayinDiv").style.display="";//打印之后将该元素显示出来(显示出"打印"和"打印预览"两个按钮,方便别人下次打印)} function printTure() //打印函数{ document.all('qingkongyema').click();//同上 document.all("dayinDiv").style.display="none";//同上 window.print(); document.all("dayinDiv").style.display="";}function doPage(){ layLoading.style.display = "none";//同上}</SCRIPT><script language="VBScript">dim hkey_root,hkey_path,hkey_keyhkey_root="HKEY_CURRENT_USER"hkey_path="\Software\Microsoft\Internet Explorer\PageSetup"'//设置网页打印的页眉页脚为空function pagesetup_null()on error resume nextSet RegWsh = CreateObject("WScript.Shell")hkey_key="\header" RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""hkey_key="\footer"RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""end function'//设置网页打印的页眉页脚为默认值function pagesetup_default()on error resume nextSet RegWsh = CreateObject("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"end function</script></HEAD><BODY background="images/background_01.gif" leftMargin=0 topMargin=0 rightMargin=0 bottomMargin=0 style="BACKGROUND-POSITION: center 50%"><DIV align=center> 你希望打印的内容.......... </DIV><DIV align="center" id="dayinDiv" name="dayinDiv"><input type="button" class="tab" value="打印" onclick="printTure();"> <input type="button" class="tab" value="打印预览" onclick="printpr();"><input type="button" name="qingkongyema" id="qingkongyema" class="tab" value="清空页码" onclick="pagesetup_null()"> <input type="button" class="tab" value="恢复页码" onclick="pagesetup_default()"></DIV></BODY></HTML> 报表打印控件wsReport4.6 求助一个诡异的写文件的问题! JQuery中怎么设置class呢? JS如何验证表单中有相同名称的字段 如何改变.redText #pid 里面的CSS属性? 求一正则 匹配日期数字的 无法加载文件的疑问 当页面最大化时没有横滚动条,非最大化时有横滚动条??如何实现? 请问Netscape是否支持DTHML?如果不支持,哪里可以找到Netscape支持的类似的? 如何判断Text1.value 如何为Iframe添加css定义? javascript中的array问题 根据下拉列表的内容选择跳转页面
{
bdhtml=window.document.body.innerHTML;
sprnstr="<!--startprint-->";
eprnstr="<!--endprint-->";
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML=prnhtml;
window.print();
window.parent.returnValue='0';window.parent.close();
}<!--startprint-->
把要打印的HTML写在这里
<!--endprint-->
晕
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=javascript>
function printpr() //预览函数
{
document.all("qingkongyema").click();//打印之前去掉页眉,页脚
document.all("dayinDiv").style.display="none"; //打印之前先隐藏不想打印输出的元素(此例中隐藏"打印"和"打印预览"两个按钮)
var OLECMDID = 7;
var PROMPT = 1;
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
document.all("dayinDiv").style.display="";//打印之后将该元素显示出来(显示出"打印"和"打印预览"两个按钮,方便别人下次打印)
}
function printTure() //打印函数
{
document.all('qingkongyema').click();//同上
document.all("dayinDiv").style.display="none";//同上
window.print();
document.all("dayinDiv").style.display="";
}
function doPage()
{
layLoading.style.display = "none";//同上
}</SCRIPT><script language="VBScript">
dim hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\Software\Microsoft\Internet Explorer\PageSetup"
'//设置网页打印的页眉页脚为空
function pagesetup_null()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="\header"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
hkey_key="\footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
end function
'//设置网页打印的页眉页脚为默认值
function pagesetup_default()
on error resume next
Set RegWsh = CreateObject("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"
end function
</script></HEAD>
<BODY background="images/background_01.gif" leftMargin=0
topMargin=0 rightMargin=0 bottomMargin=0 style="BACKGROUND-POSITION: center 50%"><DIV align=center>
你希望打印的内容..........
</DIV><DIV align="center" id="dayinDiv" name="dayinDiv"><input type="button" class="tab" value="打印" onclick="printTure();">
<input type="button" class="tab" value="打印预览" onclick="printpr();">
<input type="button" name="qingkongyema" id="qingkongyema" class="tab" value="清空页码" onclick="pagesetup_null()">
<input type="button" class="tab" value="恢复页码" onclick="pagesetup_default()">
</DIV></BODY>
</HTML>
报表打印控件wsReport4.6