SPSPilot
05-18-2006, 08:15 PM
Ok I have this page (main.html) that is loaded with an iframe (that loads in this mypage2.html) that I would like to print. How I would like it to print is when a user clicks on a Print link on the main.html page that it opens a new window with this mypage2.html and then prompts the print dialog box. After the user prints mypage2.html, the new window closes.
Well I have the following code that I added to the mypage2.html which is the page that gets loaded into the iframe:
<object id=WBControl width=0 height=0 classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2></object>
<script language=VBScript><!-- //
Sub VBPrint() On Error Resume Next
WBControl.ExecWB 6,1
End Sub
//--></script>
<script language=JavaScript><!-- //
// if browser is not IE, FF or Netscape then just prints
if (window.print) self.print();
//Checks to see if browser is IE
else if (navigator.appName.indexOf('Microsoft') !=-1) VBPrint()
setTimeout('self.close()',3000);
else if (navigator.appName.indexOf('Netscape') !=-1) VBPrint()
setTimeout('self.close()',3000);
//--></script>
Then when a user clicks on the Print link back on main.html to open the mypage2.html, the code used on the link is:
<a href="javascript:;" onClick="window.open('mypage2.html','newwin')">Print this page</a>
Well this works out well in IE but in FireFox and Netscape everytime the main.html page opens with the iframe loading this mypage2.html, Firefox and Netscape wants to print the parent page .
So my question is there is someway to make Firefox and Netscape do a similar function? Or am I just way off on my code?
Thanks for the advice.
Well I have the following code that I added to the mypage2.html which is the page that gets loaded into the iframe:
<object id=WBControl width=0 height=0 classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2></object>
<script language=VBScript><!-- //
Sub VBPrint() On Error Resume Next
WBControl.ExecWB 6,1
End Sub
//--></script>
<script language=JavaScript><!-- //
// if browser is not IE, FF or Netscape then just prints
if (window.print) self.print();
//Checks to see if browser is IE
else if (navigator.appName.indexOf('Microsoft') !=-1) VBPrint()
setTimeout('self.close()',3000);
else if (navigator.appName.indexOf('Netscape') !=-1) VBPrint()
setTimeout('self.close()',3000);
//--></script>
Then when a user clicks on the Print link back on main.html to open the mypage2.html, the code used on the link is:
<a href="javascript:;" onClick="window.open('mypage2.html','newwin')">Print this page</a>
Well this works out well in IE but in FireFox and Netscape everytime the main.html page opens with the iframe loading this mypage2.html, Firefox and Netscape wants to print the parent page .
So my question is there is someway to make Firefox and Netscape do a similar function? Or am I just way off on my code?
Thanks for the advice.