请问怎么实现打印当前网页? rt 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <object id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0 > </object> <input type=button value=Print onClick=document.all.WebBrowser.ExecWB(6,1)> <input type=button value=PrintOut onClick=document.all.WebBrowser.ExecWB(6,6)> <input type=button value=PrintSetting onClick=document.all.WebBrowser.ExecWB(8,1)> <input type=button value=PrintPreview onClick=document.all.WebBrowser.ExecWB(7,1)> <input type=button value='打印' onclick='window.print();'> 如果只需要打印网页上某个HtmlTable里的内容呢? test1为网页上一个HtmlTable的id为什么这么打印,最后打出来的是整个网页?<script lang="javascript"><!--function printable(){text=document.all.test1.InnerHtmlprint(text)}--></script> <object id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></object>实际是通过ActiveX控件来调用IE浏览器的打印功能。 可是点击按钮提示网页错误,还有就是这样是打印整个网页吗?如果要打印某个htmltable里的内容呢?谢谢! <html><head></head><body> <table border="1"> <object id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0 > </object> <tr><td> <input type="button" value="Print" onclick="document.all.WebBrowser.ExecWB(6,1)"> </td></tr> <tr><td> <input type="button" value="PrintOut" onclick="document.all.WebBrowser.ExecWB(6,6)"> </td></tr> <tr><td> <input type="button" value="PrintSetting" onclick="document.all.WebBrowser.ExecWB(8,1)"> </td></tr> <tr><td> <input type="button" value="PrintPreview" onclick="document.all.WebBrowser.ExecWB(7,1)"> </td></tr> </table></body></html>我这是一点问题也没有呀,你检查一下你是否是禁用了ActiveX 汗,现在可以了,谢谢。这是打印整个网页的吧?要是只想打印一部分比如一个HtmlTable里的内容呢? 直接打印某个Table的方法好像还没有,可以用这个方法打印它:<html><head><script language=javascript> function printChildWindow(id) { var printTableHtml = ""; printTableHtml = "<HTML><HEAD></HEAD><BODY onload='print()'><CENTER><TABLE>"; printTableHtml += document.all(id).innerHTML; printTableHtml += "</TABLE></CENTER></BODY></HTML>"; var newWindow = window.open("newWindow.html", "newWindow", "height=200,width=300"); newWindow.document.write(printTableHtml); newWindow.document.close(); }</script></head><body> <table border="1"> <tr><td> <input type="button" value="PrintTable" onclick="printChildWindow('Content1');"> </td></tr> </table> <table align="center" id="Content1" border="1"> <tr><td>a b c d</td></tr> <tr><td>a b c d</td></tr> <tr><td>a b c d</td></tr> <tr><td>a b c d</td></tr> <tr><td>a b c d</td></tr> </table></body></html> .net webform 下怎么输出html片段用于ajax调用(不拼接html) Safari浏览器里锚点链接不好用。请指教 vs.net2005里的IIS vs2005做的网站界面如何来美化~~分数不多,希望帮顶~~ 做一个简易CMC 关于dataadapter和view的问题。急。。在线等 为什么session不受用户操作的影响? 弹出对话框语句执行了,为什么看不到运行效果 如何在asp.net(C#)下面调用VB。NET的函数 开发软件项目中,对哪些方面进行管理和控制是必要的? 按钮和验证控件的问题!!! 请问大家遇到过这种怪现象吗???????
</object>
<input type=button value=Print onClick=document.all.WebBrowser.ExecWB(6,1)>
<input type=button value=PrintOut onClick=document.all.WebBrowser.ExecWB(6,6)>
<input type=button value=PrintSetting onClick=document.all.WebBrowser.ExecWB(8,1)>
<input type=button value=PrintPreview onClick=document.all.WebBrowser.ExecWB(7,1)>
为什么这么打印,最后打出来的是整个网页?<script lang="javascript">
<!--
function printable(){
text=document.all.test1.InnerHtml
print(text)
}
-->
</script>
<head></head>
<body>
<table border="1">
<object id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0 >
</object>
<tr><td>
<input type="button" value="Print" onclick="document.all.WebBrowser.ExecWB(6,1)">
</td></tr>
<tr><td>
<input type="button" value="PrintOut" onclick="document.all.WebBrowser.ExecWB(6,6)">
</td></tr>
<tr><td>
<input type="button" value="PrintSetting" onclick="document.all.WebBrowser.ExecWB(8,1)">
</td></tr>
<tr><td>
<input type="button" value="PrintPreview" onclick="document.all.WebBrowser.ExecWB(7,1)">
</td></tr>
</table>
</body>
</html>
我这是一点问题也没有呀,你检查一下你是否是禁用了ActiveX
<html>
<head>
<script language=javascript>
function printChildWindow(id) {
var printTableHtml = "";
printTableHtml = "<HTML><HEAD></HEAD><BODY onload='print()'><CENTER><TABLE>";
printTableHtml += document.all(id).innerHTML;
printTableHtml += "</TABLE></CENTER></BODY></HTML>";
var newWindow = window.open("newWindow.html", "newWindow", "height=200,width=300");
newWindow.document.write(printTableHtml);
newWindow.document.close();
}
</script>
</head>
<body>
<table border="1">
<tr><td>
<input type="button" value="PrintTable" onclick="printChildWindow('Content1');">
</td></tr>
</table>
<table align="center" id="Content1" border="1">
<tr><td>a b c d</td></tr>
<tr><td>a b c d</td></tr>
<tr><td>a b c d</td></tr>
<tr><td>a b c d</td></tr>
<tr><td>a b c d</td></tr>
</table>
</body>
</html>