...

View Full Version : print non visible page/file



foss
06-21-2002, 07:16 PM
Hi guys,

question: is it possible to print a certain file via javascript. the user pushes a button or link and than a file (htlm) will be printed, but not that file the user sees in the browser??

thanx for replies


foss

whackaxe
06-21-2002, 07:33 PM
i havent ever used the print command and i dont really know how much of a timeout it has but what you could do is make the html page with this script in it

<script>
function print_the_page()
{
document.print() //or whatever it is
setTimeout("window.close()",10000)
}
</script>

<body onload="print_the_page()">

this script will print the page when loaded and then close itself after 10 seconds. you can change that to whetever you wan tbut maybe somecomputers wront have time to get the document to the printer before it closes. but i dont really know about that

Beck
06-21-2002, 09:57 PM
I also know nothing about the print function, but I know how you can make a page users cannot see and have access to it. It involves frames, where one is 100 percent visible and the other is 0 percent visible. Just access the invisible frame using the parent object and have it print using whatever print functions are available.

<html>
<head>
<title>My title</title>
<script language="JavaScript">
<!--
function execPrint () {
parent.frames[1].document.print();
// where print() or whatever the official
// print method is for that object and browser is.
}
// -->
</script>
</head>

<frameset rows="100%,0">
<frame src="what_user_sees.html">
<frame src="hidden_page_to_print.html">
</frameset>

</html>

obviously, that what_user_sees.html page has to contain some way of accessing the frameset page's execPrint() function. This can be done by

<input type="button" value="print" onClick="parent.execPrint()">

Does that make sense? Good luck!

foss
06-22-2002, 10:54 AM
thanks to you!

the idea with the frames isn't that bad!

My question was posted, 'cause i search for a way to switch between the monitor-version of a page (black background and gray text) an the print version of the same text (white background and black text). But for this i have to go to the "Post/ request" area.

Thanks for your answers

JohnKrutsch
06-22-2002, 07:59 PM
This will work in IE:

<link rel=alternate media=print href="nicelyFormated.doc">

This way when they press print it will actually get a word doc or .pdf or diferent page to print then the one they are viewing.

You can read more about it:

http://www.dynamicdrive.com/dynamicindex9/printstyle.htm

foss
06-24-2002, 10:26 AM
Thank you John!

I missed the article in the user preference area.

I'll take this for the IE-Version of my page.
For the NN-version i take the frameset solution.

C U

chuang21
03-18-2009, 05:12 PM
Hi Guys,
Hopefully, yall still remember this topic...

I need to be able to let a user print documents like word or pdf and the frames dont seem to work. For example, I would have an html form with checkboxes that lists files in a folder held on a server (i have this made). When the user clicks the print button it will print out those files. Do you guys think this is possible?

Thanks a lot for the help!!

TinyScript
03-18-2009, 05:34 PM
Can I see the script? I hadn't even used a computer ever when this thread was created. hahaha. I have a lot of catching up to do.

I would imagine you could make the pages in their own iframe and keep it hidden or off screen, then switch it to visible, give it the print command, and then set it back to hidden. Or, I wonder if it would print while it's hidden?

Interesting. I can't wait to see what these guys think



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum