 |
| Javascript How-To Ask your "How do I do this with Javascript?" questions here. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 6th, 2004, 09:34 AM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
No print button on the paper with NETSCAPE
Hello,
I simply want to print a page. I don't want the button to be printed.
Now, if I use Explorer, with the style option media, it works fine... but does not with Netscape.
I have tried to set visibility to hidden but it does not seem to work either.
ANy idea to make it work with Netscape?
Thanks
|
|

October 6th, 2004, 04:17 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
I don't believe Netscape supports media='print' .
Try setting the display:none property instead of the visibility.
-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
|
|

October 7th, 2004, 02:47 AM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I don't understand what you mean by seeting the display:none property instead of the visibility. I thought it was what I did before... COuld you explain it please? I am rather new to Javascript and css.
Here is what I did:
.....
<style>
@media print
{
.printP {display;none;
}
</style>
.....
and then
<span class="printP">
<input type="button" onClick="window.print()" value="Print this page">
</span>
This does not work with Netscape (worked with Explorer), so I tried:
function DoPrint()
{
document.all("cmdPrint").style.visibility = "hidden";
window.print();
document.all("cmdPrint").style.visibility = "visible";
}
....
and then
<P align="right">
<input id="cmdPrint" type="button" value="Print" onclick="D
oPrint()">
</p>
It even worse....I don't even manage to get the "print screen" (I get it with Explorer though!).
|
|

October 7th, 2004, 05:43 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Fix up your style sheet:
@media print
{
.printP {display;none;
}
should be
@media print
{
.printP {display:none;}
}
If this doesn't work, try putting this in an external stylesheet (.css file) and linking to it like this:
<link rel='stylesheet' media='print' src='your_css_file.css' type='text/css'/>
HTH!
-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
|
|

October 7th, 2004, 07:54 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
> I don't believe Netscape supports media='print' .
That's true for Netscape 4, but that isn't true for Netscape 6, 7, Mozilla, Mozilla Firefox and any other Gecko-derived browser.
> I don't understand what you mean by seeting the display:none property instead of the
> visibility. I thought it was what I did before... COuld you explain it please?
The most important difference between display: none and visibility: hidden is with display: none no space is reserved for the element, whereas with visibility: hidden the space that element would normally occupy is still in the document. So with visibility: hidden, the element still exists as far as its dimensions are conserned.
HTH!
Regards,
Rich
--
[ http://www.smilingsouls.net]
[ http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
|
|

October 7th, 2004, 08:07 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Oops I meant to say Netscape does not support @media, and I don't think it does.
But I did find that Netscape supports media='print'.
-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
|
|

October 8th, 2004, 06:46 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
That isn't true either. I don't know when support for @media print began, but the latest NS 7.2, Mozilla and other Gecko browsers do support it.
Regards,
Rich
--
[ http://www.smilingsouls.net]
[ http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
|
|

October 13th, 2004, 04:49 AM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Well, I have Netscape 7.0 so it does not work.
So, you are saying that if I download Netscape 7.2 and if I put in an external css file:
@media print
{
.printHidden
{
display:none;
}
}
It will work botk with Explorer and Netscape ?
|
|

October 13th, 2004, 07:12 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
It works for me, tested on Firefox 1.0PR, Mozilla 1.8 alpha 4 and Netscape 7.0 (NS 7.0 is based on Mozilla 1.0, NS 7.2 is based on Mozilla 1.7).
I wouldn't worry as much about Netscape as I would about Mozilla Firefox. Though for the most part, if you do one thing for Gecko it works in all of them, keeping in mind that the older Netscape 7 and Mozilla releases are far more buggy than NS 7.2 and the latest Mozilla and Mozilla Firefox.
http://www.w3schools.com/browsers/browsers_stats.asp
Regards,
Rich
--
[ http://www.smilingsouls.net]
[ http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
|
|

October 13th, 2004, 09:06 AM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
OK, I have Netscape 7.0 and it does not work. Could you tell me the lines you wrote please?
I already have the following line in my jsp file:
<link rel="stylesheet" type="text/css" href="../mystyle.css">
|
|
 |