PDA

View Full Version : Java Script print question



duckmansweb
08-05-2007, 10:28 PM
hey all javascript guru's out their , i want to know if this is possible or not as i am getting mixed responces , what i want to do is , print a external document such as worddocument.doc from a html page , so click a buton and it will print the linked document , any help would be appreciated , cheers, regards Rick :confused:

Twey
08-05-2007, 10:39 PM
No.  

duckmansweb
08-05-2007, 10:48 PM
so what if i made the .doc files into a HTM document , is it then possible ? to click a print button and it will print the htm doc ?

thetestingsite
08-05-2007, 10:53 PM
If you were to make it plain text (or an HTML document), then yes you could print it out normally. Otherwise, no.

duckmansweb
08-05-2007, 10:57 PM
ok awsome , would you know of a script that would do this ? cheers

Twey
08-06-2007, 12:01 AM
<script type="text/javascript">
function latestElement() {
var e = document;
while(e.lastChild && e.lastChild.lastChild)
e = e.lastChild;
return e;
}

if(window.print) {
var a = document.createElement("a");
a.appendChild(document.createTextNode("Print"));
a.href = "#";
a.onclick = function() {
print();
return false;
};
latestElement().appendChild(a).appendChild(document.createTextNode("Print"));
a = null;
}
</script>