如何实现在页面上打印IFRAME中的文件?

shwei001 2002-05-15 01:37:54
即在本页中有一IFRAME,需要在本页上有一按钮实现打印IFRAME中文件功能
...全文
48 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wdfboy1978 2002-06-04
  • 打赏
  • 举报
回复
复制以下的代码就可以了,简单易用。

<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>
wdfboy1978 2002-06-03
  • 打赏
  • 举报
回复
不行,出现错误,win.print()拒绝访问,是怎么回事?
shwei001 2002-05-16
  • 打赏
  • 举报
回复
可以打印html,txt
但是doc打不了
孟子E章 2002-05-15
  • 打赏
  • 举报
回复
<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>
不行吗??
shwei001 2002-05-15
  • 打赏
  • 举报
回复
如果IFRAME中是一个WORD文档就打不了

用户需求有点变态,要求无论什么文档都要直接打印
孟子E章 2002-05-15
  • 打赏
  • 举报
回复
<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>

孟子E章 2002-05-15
  • 打赏
  • 举报
回复
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>
Andrawu 2002-05-15
  • 打赏
  • 举报
回复
http://www.csdn.net/expert/topic/674/674944.xml?temp=.2572595
孟子E章 2002-05-15
  • 打赏
  • 举报
回复
<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>

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧