<body>
<input onclick='prn()' type=button value=print_Iframe><br>
<iframe id=mxh src="d:\hhh.htm"></iframe>
<script>
function prn()
{
var win=window.open("about:blank")
win.moveTo(1200,1200)
win.location=document.all.mxh.src
win.print()
}
</script>

解决方案 »

  1.   

    http://www.csdn.net/expert/topic/674/674944.xml?temp=.2572595
      

  2.   

    You can try:body>
    在同一个Domain时<br>
    <input onclick='document.frames("mxh").focus();document.frames("mxh").print()' type=button value=print_Iframe><br>
    <iframe id=mxh src="d:\hhh.htm"></iframe>
      

  3.   

    <body>
    <input onclick='document.frames("mxh").focus();document.frames("mxh").print()' type=button value=print_Iframe><br>
    <iframe id=mxh src="d:\hhh.htm"></iframe>
      

  4.   

    如果IFRAME中是一个WORD文档就打不了用户需求有点变态,要求无论什么文档都要直接打印
      

  5.   

    <body>
    <input onclick='prn()' type=button value=print_Iframe><br>
    <iframe id=mxh src="d:\xx.doc"></iframe>
    <script>
    function prn()
    {
    var win=window.open("about:blank")
    win.moveTo(1200,1200)
    win.location=document.all.mxh.src
    win.print()
    }
    </script>
    不行吗??
      

  6.   

    可以打印html,txt
    但是doc打不了
      

  7.   

    不行,出现错误,win.print()拒绝访问,是怎么回事?
      

  8.   

    复制以下的代码就可以了,简单易用。<html>
    <head>
    <script language="javascript">
    function prn()
    {
    mxh.focus();
    print();
    }
    </script>
    </head><body>
    <input onclick="prn()" type="button" value="print_Iframe"><br>
    <iframe id=mxh src="http://www.google.com" width="500" height="300" ></iframe>
    </body>
    </html>