Link to home
Start Free TrialLog in
Avatar of Dean OBrien
Dean OBrienFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Using javascript: Sending a word file straight to print!

Hi,

I would like to print a specific word file, using javascript.

i.e. something like  <input type="button" onclick="Print(wordfile.doc);">

But i am unsure on the correct procedure.

Any help would be greatly appreciated.

Easynow
Avatar of kolpdc
kolpdc

normal html and javascript do not support such a print-command like your's shown above. could be that there is a "special" microsoft-VERSION that is able to handle such a problem. but there is the problem then that no other browser will support this.
the ie is able to load a word-file directly into browsers view-area. you only have to put a link onto the word-document and the client-computer has to have office installed. then the user may print the document.

the javascript-code working with nearly all browsers should be:

<html><head><title>Test</title>
</head><body>
<a href="javascript:window.print()">Print this page...</a>
</body></html>

some browsers do not support it. and the code only prints the currently shown page in browser (html, ...)
ASKER CERTIFIED SOLUTION
Avatar of Shalom Carmel
Shalom Carmel
Flag of Israel image

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
Nice solution!... but (always a but) ... we've just tried to use it from a flash movie, and it gets unpredictable behavours, sometimes it prints the html page instead of the actual .doc file, other times just prints part of the document. We're using IE 6 in all cases, windows 2000 profesional and windows xp, no matter the window's version nor the explorer's it gives the same problem...

I didn't make too much tests using just the html page without flash, but, should anyone knows if the problems came from the flash movie??

NOTE: I've just used the

getURL("javascript:setPrintedPage('wordocu.doc');");

in the actionscript code...

Thanks, Hans.

Hey,
I've never tried it with flash actionscript, but it always works fine in a regular browser.

Cheers,
ShalomC