位于同一个父页面的两个框架间,
比如有"RightWin"和"WorkWin"两个框架,在"RightWin"里有个按钮print,要实现功能为打印WorkWin的页面内容,我的语句是这么写的: function Print(){ window.parent.frames("WorkWin").window.print(); }
但是结果却是打印出了RightWin中的内容
解决方案:
FrameSet内容
<
frameset
cols
="20%,*"
>
< frame name ="RightWin" src ="RightWin.htm" >
< frame name ="WorkWin" src ="Workwin.htm" >
</ frameset >
< frame name ="RightWin" src ="RightWin.htm" >
< frame name ="WorkWin" src ="Workwin.htm" >
</ frameset >
RightWin.htm内容:
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
< head >
< title ></ title >
< script language ="javascript" type ="text/javascript" >
function Print() {
alert(window.parent.frames( " WorkWin " ).name);
// window.parent.frames("WorkWin").print();
parent.WorkWin.focus()
parent.WorkWin.print()
}
</ script >
</ head >
< body >
rightwin
< input id ="getPrint" type ="button" value ="Print" onclick ="Print();" />
</ body >
</ html >
< head >
< title ></ title >
< script language ="javascript" type ="text/javascript" >
function Print() {
alert(window.parent.frames( " WorkWin " ).name);
// window.parent.frames("WorkWin").print();
parent.WorkWin.focus()
parent.WorkWin.print()
}
</ script >
</ head >
< body >
rightwin
< input id ="getPrint" type ="button" value ="Print" onclick ="Print();" />
</ body >
</ html >
打印frame窗口要 先进行 frameName.focus();
另外注意路径问题。而且打印机设置要"只打印当前框架"