Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

BBS: Re: Printing in IE4 - September 01, 1998 at 05:51:32

You are here: irt.org | BBS | Re: Printing in IE4 [This BBS is closed]

Posted by Martin Webb on September 01, 1998 at 05:51:32:

In Reply to: Printing in IE4 posted by Dave Hufnagle on August 31, 1998 at 14:59:30:

: I need a script to print a frame using IE4. The script "window.print ()" works for Navigator but not IE4. Please HELP ME!!!!

: Thanks in advance!

: Dave Hufnagle
: DJHufnagle_ARAS@Hotmail.com

Let me try again :)

Try the following, no gurantees given:

<script language="javascript">
DA = (document.all) ? 1 : 0
//window.onerror=handle_error

function handle_error ()
{
alert ("\nNothing was printed. \n\nIf you do want to print this page, then\nclick on the printer icon in the toolbar above.")
// to cancel the script error warning
return true;
}
</script>

<form>
<Input type=button value="Print Page" onclick="window.print ();">
</form>

<SCRIPT LANGUAGE="VBScript">
sub window_onunload

on error resume next

' Just tidy up when we leave to be sure we aren't
' keeping instances of the web-browser control in memory
set WB = nothing
end sub

sub print

OLECMDID_PRINT = 6
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_PROMPTUSER = 1


on error resume next

'IE4 object has different command structure
if DA then
call WB.ExecWB (OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER)

else
call WB.IOleCommandTarget.Exec (OLECMDID_PRINT ,OLECMDEXECOPT_DONTPROMPTUSER,"","")

end if

if err.number <> 0 then
if DA then ' IE4 they probably cancelled
alert "Nothing Printed :" & err.number & " : " & err.description
else
handle_error ' ie3x give alternate instructions
end if
end if
end sub

'This will be interpreted during loading.
'It will write out the correct webbrowser object depending
'on the browser version. To be sure it works, make sure you
'include this script block in between the body tags.

if DA then
'this must be IE4 or greater
wbvers="8856F961-340A-11D0-A96B-00C04FD705A2"
else
'this must be IE3.x
wbvers="EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B"
end if

document.write "<OBJECT ID=""WB"" WIDTH=0 HEIGHT=0 CLASSID=""CLSID:"
document.write wbvers & """> </OBJECT>"
</SCRIPT>


Follow-ups:

You are here: irt.org | BBS | Re: Printing in IE4 [This BBS is closed]

©2018 Martin Webb