Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Print button (or link) invisible to printer

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
LisaWi
Asked:
LisaWi
  • 4
  • 4
1 Solution
 
brigmarCommented:
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
 
LisaWiAuthor Commented:
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
 
brigmarCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LisaWiAuthor Commented:
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
 
brigmarCommented:
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
 
LisaWiAuthor Commented:
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
 
brigmarCommented:
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
 
LisaWiAuthor Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now