Click to See Complete Forum and Search --> : Printing Image


Susan
02-21-2003, 02:21 PM
I am trying to create a script that would allow person to print off image. I am having trouble in that it doesn't matter what option they choose (Onclick), the image appears in the window and I do not know how to get around that. I know it is due to the anchor tag being executed.

Thanks for any help!

Susan
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2800.1141" name=GENERATOR></HEAD>
<BODY>
<SCRIPT language=JavaScript>
<!-- Hide from Old Browsers
// End hiding script from old browsers -->
function confirm_entry()
{
onClick = temp = window.confirm("Click OK to Print Application");
if (temp==true){
function myprint(){
window.focus();
window.print()
}
}
else
{
// Output when Cancel is clicked
}
}
confirm_entry()
-->
</SCRIPT>
<A href="javascript:window.print()"><IMG src="PrtApp_files/GF1.gif"
</A></BODY></HTML>

Susan
02-21-2003, 08:04 PM
Thanks but I would like to get rid of it after it prints, so do I need to close the window somehow? I am a newbie to this and I have tried to figure out how to put it in a separate routine for if I wanted to print the image only so that the image would not show up if the person did not want to print the image. But I don't know how to structure subroutines. :confused:

Susan
02-22-2003, 05:20 PM
Thank you very much. But I am not satisfied with yet with what I have. My problem is that when the person clicks OK to print, then the picture comes up with that floating toolbar and then the Printer preview screen (I have the printer set that wayfor print preview) and then if I print it, that picture is on the screen with the floating toolbar again (after the Print), and it seems like I am in a loop. I don't know if I have explained this very well but I think it is the way that IE6 and the Printer interface with JavaScript. Is it because of the OnClick and then you have to click to Print, and then Click to close the browser window and all this clicking is confusing? I wanted to make this neat and easy but I am afraid it would be very confusing to another person. Thanks for any help in advance!

<SCRIPT language=JavaScript>
<!-- Hide from Old Browsers
// End hiding script from old browsers -->
// print the image function
function printImage(src) {
myWin = window.open('', 'myWin', 'width=800,height=600');
var str = '<img src="'+src+'" border="0">';
myWin.document.open();
myWin.document.write(str);
myWin.document.close();
myWin.focus();
myWin.print();

}
// close the window function
function closeWin() {
setTimeout('closeWin()',6000);
myWin.close();
myWin = null;
}
function confirm_entry(){
onClick = temp = window.confirm("Click OK to Print Application");
if (temp==true){
printImage("PrtApp_files/GF1.gif");
}
else
{
// Output when Cancel is clicked
}
}
confirm_entry()
window.close();
</SCRIPT>

Susan
02-23-2003, 06:08 AM
I appologize. I have tried it various ways. It keeps evolving. But if the Print option is selected, the Picture comes up after the print in the browser again with that floating toolbar.

Let me explain about the picture. It is a gif image of an application for an outdoor art shore. I wanted artists to be able to print it off which will save time having to fax it to them.
The art center printed it in landscape format which is cut off if printed, so I generated gif version and rotated 90 degrees. Although browser IE setting will affect print, it is legible and director is satisfied with it.

I don't like the way the picture remains in the browser with the floating tool bar after the print. I can easily print it off but with
that picture appearing again and again, it would be easily to print off several copies and could be very aggravating to someone. The other option with the Cancel works nicely.

<SCRIPT language=JavaScript>
<!-- Hide from Old Browsers
// End hiding script from old browsers -->
function printImage(src) {
myWin = window.open('', 'myWin', 'width=800,height=600');
var str = '<img src="'+src+'" border="0">';
myWin.document.open();
myWin.document.write(str);
myWin.document.close();
myWin.focus();
myWin.print();
setTimeout('closeWin()',60000);
}
function closeWin() {
myWin.close();
myWin = null;
}
function confirm_entry() {
onClick = temp = window.confirm("Click OK to Print Application");
if (temp==true){
printImage("GF1.gif")}
// Output when Cancel is clicked
}
confirm_entry()
</SCRIPT>

Please let me thank you for your time. I am a volunteer and do not receive pay. I enjoy the computer and am helping out the local art center where I live.

At this point, I don't know if there is a nice solution with JavaScript. Is it the way it interfaces with the printer and IE?

Susan
02-23-2003, 01:48 PM
Printing the picture is fine. It is how to exit the screen. The picture takes up the whole screen and has the floating toolbar in the upper left. I know how to close the screen by right clicking on the IE icon in the upper left hand corner and then close. But to a person who is just trying to print of the application, the picture taking up the screen with the toolbar could be confusing. I don't think it is obvious to a greenhorn what to do after he/she manages to print the picture! It might seem that one is in a loop with the picture appearing in the browser after the print has finished! I hope that I have explained this better.

Susan

Susan
02-23-2003, 07:48 PM
Again I thank you for your time. I understand the Timeout but I am stuck with the application in the window. I have made some screen prints and you can view them at the following:
http://www.easternshoreartcenter.com/prnt1.htm


You are right! I guess one minute can seem like a long time when you are printing. But the timeout just clears the window.
I probably need to reduce the time.

Now I will incorporate this into the pages and I am not sure about how the transfer of control from one page to another and back will work but I plan to find out.

Thank you for your time and patience. I hope I was not too frustrating to work with.

Susan

bethan
03-20-2005, 03:08 PM
I know this might be a pretty old thread but i have an answer! put this code just below the html tag of your page to get rid of the toolbar:

<META HTTP-EQUIV="imagetoolbar" CONTENT="no">

Bethan :)