Link to home
Start Free TrialLog in
Avatar of jwiebe
jwiebe

asked on

Automatic printing from /any/ browser

How can I automatically (Onload) print the current document, no matter which browser (IE3.x/4.x/5.X/NS ditto) the cleint is using? I know about the window.print() or print() function of NS, but how can I use anything equivalent on the IE?
Avatar of davlun20080
davlun20080

This is from active question in javascript area, see https://www.experts-exchange.com/Computers/Programming/Languages/JavaScript/Q.10183680

<HEAD>
<TITLE>Test</TITLE>
<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><!-- //
function startprint(){
if (window.print)
   self.print();
else if (navigator.appName.indexOf('Microsoft') !=-1)
   VBPrint(); }
// --></SCRIPT>
</head>
<body onLoad="startprint()">

This did not work for me in NS but you get the idea, perhaps your questions would be better served in the JS area.

davlun
Avatar of jwiebe

ASKER

Thanx, sorry about placing the question here... newbie...
Hope I did not offend, did not mean to if I did.  Just wanted to make sure you obtained the best answer possible.  Could not offer more on the script myself, best I can do.

davlun
window.print() is available in Netscape 4.x and IE5.  IE4 can use the print.js metioned in the question you got a link to.  for IE3 (and also IE4) you can use a script found on irt.org, URL is http://www.irt.org/script/481.htm

to figure out what browsers you're talking to you'll have to do a bit of browser sniffing.
ASKER CERTIFIED SOLUTION
Avatar of komandur
komandur

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Komandur,
I know this isn't my question, but does your answer mean it will print from the users browser the minute the page loads or from jwiebe's pc when he double clicks on a file?  Because if all it takes to print is getting the command netscape /print -- how do you add that to a web page?  Secondly, will this work on older browsers and IE?

Sorry to intrude jwiebe, I am REALLY interested in this question as it is something that I have thought about before.

davlun
Avatar of jwiebe

ASKER

Ok, if you want to print a page upon loading just add onLoad="javascript:print()" into your <body>-tag. this works with pretty much all NSs and it's upposed to work with IE5.
I wanted to get a solution that works for both, IE (4) and NS, for this, try the link mentioned above (with didn't work for me :-( ).

jwiebe


Thanks Jwiebe, I knew about the print() but it seemed Komandur had a different solution than that.  Just thought I would check to make sure I was following the thread right.  I do know that the script from the javascript area answered by mplungjan does work for ie.  But it sure would be nice to be able to print onload for both (especially with no prompts.
davlun
Davlun,

Yes by using my method(b) you can make _any_ 'html' file automatically printed by double clicking on it. Basically all I am trying to do is change the command of "open" to "print". This will not work unattended in IE since it expects you to press OK on the print dialog box. Whereas Netscape does a neat job on this front.

kannan.

hmmm... I can't really understand how the registry editing et all will answer the question here.  it'll make an HTML page when double-clicked from Explorer print, but is that really what's wanted here?

I hope jwiebe could clarift a bit.
Now nettrom's comments are a little in line with what I was thinking at first, but for some reason I thought what was proposed would work from browser.  Jwiebe, what is it you are trying to do, automatically print a page being viewed by a user or print by double-clicking from explorer.

davlun
Reading his original question again it says "onload" printing only. Since he has not accepted the proposed "onload", I have given the other choices.

kannan.

GREETINGS!

This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
https://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange