|
-
Jan 7th, 2004, 09:36 AM
#1
Thread Starter
Frenzied Member
print page without printing link
I saw a script to do this the other day and didn't think I'd need it, but now I do.
I want to add a link after some output that the user will be printing, but I don't want the link/button to show up on the printout. Does anyone know how to do this?
-
Jan 7th, 2004, 09:39 AM
#2
Frenzied Member
I can't think of how this script would work, but here's how you could do this:
make them use a print button on your page, not the file>>print button. Then when they press the button. hide a DIV which contains all the fields you want hidden and then print the page.
Have I helped you? Please Rate my posts. 
-
Jan 7th, 2004, 09:45 AM
#3
Thread Starter
Frenzied Member
I think that's pretty much how it worked. Before it called the print function, it hid the button.
I guess my problem is that I don't know how to do that.
-
Jan 7th, 2004, 09:59 AM
#4
Thread Starter
Frenzied Member
found it:
Code:
<script language="JavaScript">
function printPage() {
if(document.all) {
document.all.divButtons.style.visibility = 'hidden';
window.print();
document.all.divButtons.style.visibility = 'visible';
} else {
document.getElementById('divButtons').style.visibility = 'hidden';
window.print();
document.getElementById('divButtons').style.visibility = 'visible';
}
}
</script>
<div id="divButtons" name="divButtons">
<input type="button" value = "Print" onclick="printPage()">
<input type="button" value = "Close" onclick="JavaScript:window.close();">
<hr noshade>
</div>
-
Jan 7th, 2004, 10:32 AM
#5
you could also specify a "print" CSS file that would hide the div....
At least that's how it is supposed to work... browser permitting....
Which means if it works in IE, it won't work anywhere else, and vice versa....
Haven't tried it though... yet... plan to some day.
TG
-
Jan 7th, 2004, 12:12 PM
#6
Frenzied Member
the script above does exatcly what I said.
but it only works in IE. Change all alls to getElementById()
eg
document.all.wee
to:
document.getElementById('wee')
Have I helped you? Please Rate my posts. 
-
Jan 7th, 2004, 12:45 PM
#7
Thread Starter
Frenzied Member
that's in the else.
-
Jan 7th, 2004, 12:53 PM
#8
techgnome's stuff is in theory the best.
Code:
<style type="text/css" media="print">
#printButton {
visibility: hidden;
}
</style>
The nice thing is that it works even with a normal print command. The downside is IE.
You should have both. The IE solution in JS and the Mozilla/Opera etc. solution in CSS.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 7th, 2004, 12:56 PM
#9
Thread Starter
Frenzied Member
Since this is an in-house solution, I think I'll stick with the IE only version since that is all we use.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|