Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1187
  • Last Modified:

Print in IE without displaying print dialog?

Hi,

I want to print a frame in a frameset without prompting for print-dialog (or any other dialog).

I have written some functions and tried some other solutions with Active X / JavaScript , but wihout success -:(

e.g.

function printNoDialog(whichFrame) {
      parent[whichFrame].focus();
      document.body.insertAdjacentHTML("beforeEnd", "<object id='idWBPrint' width=0 height=0   classid='clsid:8856F961-340A-11D0-A96B-00C04FD705A2'></object>");

      idWBPrint.ExecWB(6, -1);
      idWBPrint.outerHTML = "";
      
                // or

      // execScript("on error resume next: WebBrowser1.ExecWB 6, 0", "VBScript");
      // execScript('on error resume next: WebBrowser1.outerHTML = ""', 'VBScript');
      
}

and

http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20966791.html


Any tips? Code that works with IE 6+.

thanx in advance!


Michael G
0
morpheous_
Asked:
morpheous_
  • 5
  • 5
1 Solution
 
sgalzinCommented:
hi,

this seems to work (i'm like FtB, I'm so surprised though !!) :

*** file frame.html ***
<html>
<frameset cols="100,*"><frame name="left" src="left.html"><frame name="main" src="main.html"></frameset>
</html>
*** end of file frame.html ***

*** file main.html ***
<html><body>Main !</body></html>
*** end of file main.html ***

*** file left.html ***
<html><head>
<script language="VBScript">
SUB Print()
    OLECMDID_PRINT = 6
    OLECMDEXECOPT_DONTPROMPTUSER = 2
    OLECMDEXECOPT_PROMPTUSER = 1
    'Bring focus to the document so that it will be what prints:
    window.parent.frames.main.document.body.focus()
    'Call the "Print" command. Since the Internet Explorer/DOM didn't add
    'the "print()" method until 5.0
    on error resume next
    call IEWB.ExecWB (OLECMDID_PRINT, -1)
    if err.number <> 0 then
        alert "Nothing Printed"
    end if
END SUB
</script>
</head><body><object id="IEWB" width="0" height="0" classid="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></object><a href="javascript:Print ();">print</a></body></html>

*** end of file left.html ***

0
 
morpheous_Author Commented:
It's not working.

I am receiving "Nothing Printed".

I have tried printing any frame, but I receive always Nothing Printed.

I run latest IE, 6.0.2900.2180 - SP2


This is how my frameset lookes like:

<frameset rows="120,*,40" frameborder="NO" border="0" framespacing="0">
  <frame src="max_top.aspx" name="max_top" scrolling="no" noresize>
  <frameset cols="10,*,10" frameborder="NO" border="0" framespacing="0">
    <frame src="max_left.aspx" name="max_left" scrolling="no" noresize>
    <frame src='http://OtherServerWithinSameDomain/body.xml' name="max_bottom">
    <frame src="max_right.aspx" name="mm_max_right" scrolling="no" noresize>
  </frameset>
  <frame src="max_copyright.aspx" name="max_copyright" scrolling="no" noresize>
</frameset>



max_top.aspx (max_top frame)



<head>

<script language="VBScript">

SUB Print()
                OLECMDID_PRINT = 6
      OLECMDEXECOPT_DONTPROMPTUSER = 2
      OLECMDEXECOPT_PROMPTUSER = 1
      'Bring focus to the document so that it will be what prints:
      window.parent.frames.max_bottom.document.body.focus()
      'Call the "Print" command. Since the Internet Explorer/DOM didn't add
      'the "print()" method until 5.0
      on error resume next
      call IEWB.ExecWB (OLECMDID_PRINT, -1)
                  
      if err.number <> 0 then
             alert "Nothing Printed"
      end if
END SUB

</script>      

</head>

<body>

<object id="IEWB" width="0" height="0" classid="clsid:8856F961-340A-11D0-A96B-00C04FD705A2" VIEWASTEXT></object>

<a href="javascript:Print();">print</a>

</body>



Regards,

Michael PG
0
 
sgalzinCommented:
hi,

just to get the browser issues out of the way, did you try my exact code ? with the three files above ?

i've tried your frameset configuration and it still works fine on my browser (6.0.2800.1106 - SP1).

stephane.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
morpheous_Author Commented:

Error number I receive when i print is 70.
That stand for Access Denied.

As you can notice the frame I am trying to print is located on the same domain, but on the other server.

I have also tried to print other frames in the frameset but without success.

Any Ideas ?
0
 
morpheous_Author Commented:
I have tested your example above. On three computers in the domain. Both with SP1 and SP2.
Same error.
0
 
sgalzinCommented:
let's do it little by little in order to see where the pb is :

- by putting everything on the same server do you get an error ?
- by putting all the files on the local computer and testing locally do you get an error ?


0
 
morpheous_Author Commented:
1. yes
I run .Net project on IIS on local machine and get an error.

2. yes
I tried running frame.html (your example with two frames) from local filesystem, same error.

I am receiving "Nothing Printed". Error 70.
0
 
sgalzinCommented:
ok. so bascially, the very first example works on my PC but not on yours. let's wait for some others to come and help us on this as I unfortunately can't do much more ... I have another PC I will try on next week-end, just in case there is another version of IE.

oh, one more thing : does the simple example given here work ?
http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20966791.html

without frames ? if it doesn't, then that means Microsoft finally dealt with this security issue ! you see, it really isn't normal for the browser to enable printing without confirmation, so maybe IE6SP2 has pathced this, which is why it doesn't work on your IE ...

stephane.
0
 
morpheous_Author Commented:
No, that example doesn't work either. That's the one I first checked.

As I mentioned before, i have tested script both on SP1 clients in the domain and SP2 clients in the domain. Same problem.
0
 
sgalzinCommented:
i am almost certain we're dealing with a security exploit which has been patched ... i'm checking it out, i'll keep you posted !

stephane.
0
 
ee_ai_constructCommented:
Closed, 290 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now