Solved

Print button (or link) invisible to printer

Posted on 2000-03-20
8
157 Views
Last Modified: 2008-02-26
I need to open a new window with no toolbar. But, I need to provide print functionality.  I've tried this solution:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=javascript&qid=10017405 &search=

The print button appears to be replaced, then the print dialogue box appears. However, when the page is printed the print button image is still there. Also, after the page is printed the print button image does not reappear in the browser window. Does anyone know why? Or does anyone know any other way of providing a print button that will not show on the printed report?

Any help would be greatly appreciated!!

Here's my code:

onePixel = new Image()
printImage = new Image()
onePixel.src = "/home/images/email_off.jpg"    // This is a blank image
printImage.src = "/home/images/printImage2.gif"

function printPage(){
 self.print()
 document.printButton.src=printImage.src
}

<TD WIDTH="100%" ALIGN="center"><A HREF="#" onclick="document.printButton.src=onePixel.src;Javascript: printPage()"{><IMG SRC="/home/images/printImage2.jpg" HEIGHT="25" WIDTH="50" BORDER="none" NAME="printButton" alt="Print Page"></A></TD>
0
Comment
Question by:LisaWi
  • 4
  • 4
8 Comments
 
LVL 4

Expert Comment

by:brigmar
ID: 2637384
instead of flipping the image, try just changing the visibility of the image..

to hide the image..

document.printButton.style.visibility = "hidden";

to show it:

document.printButton.style.visibility = "visible";

or..

How about putting the report and print button into different frames, and calling the print() method of the sibling frame?

e.g.
parent.report.print();
or
top.report.print();

Brian
0
 

Author Comment

by:LisaWi
ID: 2637455
Thanks, Brian. I tried it and it didn't work. I get "document.printButton.style has no properties."

I'm kind of a newbie to HTML and Javascript. Is there something else I need to do to use the "visibility" attribute?
0
 
LVL 4

Expert Comment

by:brigmar
ID: 2637552
You're using Netscape... my mistake.

add this at the end of your <body> (just before the </body> tag.)

<script language="javascript"> <!--
var isIE = (document.all)?true.false;
var objStyle = document.images["printButton"];
if(isIE) {
 objStyle = objStyle.style;
}

function printPage() {
  objStyle.visibility = (isIE)?"hidden":"hide";
  self.print();
  objStyle.visibility = (isIE)?"visible":"show";

}

//-->
</script>

However.. I think my second 'solution' is cleaner.

The window you open without the toolbar would be a frameset.

<frameset rows="40,*">
 <frame name="btn" src="printbutton.html">
 <frame name="report" src="report.html">
</frameset>

the printbutton.html would look something like this:
<html>
 <body>
  <form name="f1">
   <input type="button" value="Print Report" onclick="parent.report.print();">
  </form>
 </body>
</html>


Brian
0
 

Author Comment

by:LisaWi
ID: 2638413
Thanks for the clarification. However, I still wasn't able to get it to work. It could very well be due to my inexperience...

I've actually already tried the frames method, and it works well for one of my reports. I'm having trouble with the other ones, though. They are invoked using a variable for the URL:

function PatRecordReportWindow() {
patRecWindow = window.open(sPatRecordReportURL', "PatRecReport",
'scrollbars=yes, width=100, height=100')
}


"sPatRecordReportURL" gets it's value from a cookie. I can't figure out how to pass this value to my Frameset. Any thoughts?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:brigmar
ID: 2640705
Create a frameset for each report. You can use the same button code.

ie.. for report A, you call reportaframe.html, a frameset containing printbutton.html and reporta.html

for report B, you call reportbframe.html, a frameset containing printbutton.html and reportb.html

Just make sure the frame name for the bottom frame stays as 'report'.

Brian
0
 

Author Comment

by:LisaWi
ID: 2640889
I understand that I need a unique frameset for each report. What I don't understand is how to get my variable value for "report B" into my frameset so that it knows which page to display.

The page which calls the report gets a cookie value to determine if the user is authorized to view the report. It not, an error page is displayed. Otherwise, they get the report. (See my code snippet in my previous comment.) How do I pass the variable value to the frameset?

Thanks for your time!
-Lisa
 
0
 
LVL 4

Accepted Solution

by:
brigmar earned 100 total points
ID: 2640988
If I'm following this correctly:

When you select a report from a page, the page will examine a cookie for authorisation. This authorisation takes the form of a URL which either points to the actual report or to an error page. You want to pass this URL into the frameset?

Is this correct ?

I have a feeling this is insecure. A user without authorisation need only look at the source of the authorising page to determine what the successful URL would be, and hence run the report. I would say that the authorisation should take place on the server-side before anything is written to the browser.
ie. The client requests the report. The server checks for authorisation and returns a report or an authentication failure page.

Brian
0
 

Author Comment

by:LisaWi
ID: 2641058
Thanks, Brian. You've given me several answers to my question which are all perfectly good, they just don't seem to work for my particular situation. However, I now feel I can talk a bit more intelligently to the "gurus" here at my company about the issues I'm having with this assignment.

Thanks again for your time!
-Lisa W.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now