try:(在IE5.5以上)<object id="factory" style="display:none" viewastext classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360"></object>
<script defer>
function window.onload() {
factory.printing.header = ""
factory.printing.footer = ""
factory.printing.leftMargin = 0.75
factory.printing.topMargin = 1.5
factory.printing.rightMargin = 0.75
factory.printing.bottomMargin = 1.5
}</script><p><input type="button" value="打印本页"
onclick="factory.printing.Print(false)">
<input type="button" value="页面设置"
onclick="factory.printing.PageSetup()">
<script defer>
function window.onload() {
factory.printing.header = ""
factory.printing.footer = ""
factory.printing.leftMargin = 0.75
factory.printing.topMargin = 1.5
factory.printing.rightMargin = 0.75
factory.printing.bottomMargin = 1.5
}</script><p><input type="button" value="打印本页"
onclick="factory.printing.Print(false)">
<input type="button" value="页面设置"
onclick="factory.printing.PageSetup()">
<a href="#" onclick=document.all.WebBrowser.ExecWB(6,1)>打印</a>
<a href="#" onclick=document.all.WebBrowser.ExecWB(8,1)> 页面设置</a>
<TABLE border=1 borderColor=#000000 cellPadding=0 cellSpacing=0 style="HEIGHT: 107px; WIDTH: 169px">
<TBODY>
<TR>
<TD> 1212</TD>
<TD> 333</TD>
<TD> ddd</TD>
<TD> fff</TD>
<TD> tttt</TD></TR>
<TR>
<TD> 1212</TD>
<TD> 1231</TD>
<TD> 131</TD>
<TD> 313</TD>
<TD> 1313</TD></TR>
<TR>
<TD> dsfsad</TD>
<TD> fasdf</TD>
<TD> dsfs</TD>
<TD>asd </TD>
<TD> adsfsdf</TD></TR>
<TR>
<TD> asdf</TD>
<TD> asdf</TD>
<TD> asdf</TD>
<TD> adsf</TD>
<TD> asdf</TD></TR>
<TR>
<TD> adf</TD>
<TD> adsf</TD>
<TD> adsf</TD>
<TD> asdf</TD>
<TD> asdf</TD></TR></TBODY></TABLE></DIV></HTML>
<input type="button" value="选择表格后打印" onclick="selPrint();"><script language="javascript">
var win ;
function selPrint(){
var el = null
var selObj = document.selection.createRange();
var selType = document.selection.type;
if (selObj.parentElement != null) {
el =getEl("TD",selObj.parentElement())
if (!el) el = getEl("TR",selObj.parentElement())
if (!el) el = getEl("TABLE",selObj.parentElement())
//el = getEl("TABLE",selObj.parentElement()) ;
if (el!=null){
doc ="<TABLE "+(((el.border=="")||(el.border=="0"))?"class=\"NOBORDER\"":"")+(el.cellPadding!=""?"cellPadding=\""+el.cellPadding+"\" ":"")+(el.cellSpacing!=""?"cellSpacing=\""+el.cellSpacing+"\" ":"")+(el.border!=""?"border=\""+el.border+"\" ":"")+(el.borderColor!=""?"bordercolor=\""+el.borderColor+"\" ":"")+(el.background!=""?"background=\""+el.background+"\" ":"")+(el.background!=""?"bgColor=\""+el.background+"\" ":"")+">" ;
doc = doc+el.innerHTML+"</table>" ;
win= window.open("","");
win.document.writeln(doc) ;
win.print();
}
}
}function getEl(sTag,start)
{
while ((start!=null) && (start.tagName!=sTag)) start = start.parentElement;
return start;
}</script>