4、〖打印〗命令的实现 
  [格式]:document.execcommand("print")
  [说明]当然,你必须装了打印机!
  [举例]在<body></body>之间加入:
  <a href="#" onclick=document.execcommand("print")>打印</a>参照这个下.我没有做过啊

解决方案 »

  1.   

    <head>
    <title>MeadCo's ScriptX: Basic printing</title>
    <style>
    html      { font: 9pt / 13pt Verdana; color: black }
    input        { font: 9pt Verdana; color: black; width: 115pt }
    input.ie55   { display: none }
    body         { background-color: gainsboro; padding: 10pt }
    li      { margin-top: 4pt }
    p            { margin-top: 6pt; margin-bottom: 6pt }
    h2      { font:bold 16pt / 18pt Verdana }
    </style><!-- special style sheet for printing -->
    <style media="print">
    .noprint     { display: none }
    </style>
    </head><body scroll="auto"><!-- MeadCo ScriptX Control -->
    <object id="factory" style="display:none" viewastext
    classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
    codebase="http://localhost/javascript/myjs/htm/print/ScriptX.cab#Version=6,1,431,2">
    </object><script defer>
    function window.onload() {
      factory.printing.header = "MeadCo's ScriptX: Basic printing example"
      factory.printing.footer = "The de facto standard for advanced web-based printing"
      factory.printing.portrait = false  // enable control buttons
      var templateSupported = factory.printing.IsTemplateSupported();
      var controls = idControls.all.tags("input");
      for ( i = 0; i < controls.length; i++ ) {
        controls[i].disabled = false;
        if ( templateSupported && controls[i].className == "ie55" )
          controls[i].style.display = "inline";
      }
    }
    </script><h2>MeadCo's ScriptX: Basic printing example</h2><p>This page illustrates the Basic use of <a title= "Click here to go to the ScriptX home page " href="http://www.meadroid.com/scriptx/index.htm" target="site">ScriptX</a>.</p><ul>
     <li>The page sets a custom header and footer, and switches page orientation to
      landscape on printout</li>
     <li>The control buttons will not appear on the print-out</li>
     <li>The user's default printing settings will be automatically restored upon leaving the document</li>
    </ul><!--
    <p><b>Important note for users of IE 5.5 :</b> A major code defect in this version of Internet Explorer may result in unwanted behaviour if you invoke the Page Setup dialog too many times in any one browser session. This bug has been fixed in IE 6.0.</p>
    --><hr size="1" color="dimgray"><div id=idControls class="noprint">
     <b>Click one of the following buttons:</b> <p><input disabled type="button" value="Print the page"
     onclick="factory.printing.Print(true)">
     <input disabled type="button" value="Print the IFRAME"
     onclick="factory.printing.Print(true, idFrame)">
     <input disabled type="button" value="Page Setup..."
     onclick="factory.printing.PageSetup()">
     <input class=ie55 disabled type="button" value="Print Preview..."
     onclick="factory.printing.Preview()"><hr size="1" color="dimgray"></div><p><iframe name="idFrame" width="100%" height="60%" src="frame.htm">
    </iframe></body>
      

  2.   

    只是想用类似document.execcommand("print")的语句,来实现打印预览
      

  3.   

    testwb.htm<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>打印预览</title>
    </head>
    <script language="JavaScript" type="text/JavaScript">
    function openSrc(){
    var newwin = window.open(document.all.wb.src);
    newwin.test();
    newwin.close();
    }
    </script><body>
    <input type="button" name="Submit" value="预览" onClick="openSrc()">
    <iframe name="wb" src="test.htm"></iframe>
    </body>
    </html>test.htm<html>
    <head>
    <meta http-equiv="Content-Type" content="Application/msword">
    <title>test</title>
    </head>
    <script language="JavaScript" type="text/JavaScript">
    function test(){
    WebBrowser.ExecWB(7,1);
    }
    </script><body>aaaaaaa<object ID='WebBrowser' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>
    </body>
    </html>如果要打印iframe中的内容这个是可以的。