p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   Javascript How-To (http://p2p.wrox.com/javascript-how-87/)
-   -   No print button on the paper with NETSCAPE (http://p2p.wrox.com/javascript-how/19473-no-print-button-paper-netscape.html)

elisabeth October 6th, 2004 09:34 AM

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


Snib October 6th, 2004 04:17 PM

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 ;)

elisabeth October 7th, 2004 02:47 AM

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!).





Snib October 7th, 2004 05:43 PM

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 ;)

richard.york October 7th, 2004 07:54 PM

> 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

Snib October 7th, 2004 08:07 PM

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 ;)

richard.york October 8th, 2004 06:46 AM

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

elisabeth October 13th, 2004 04:49 AM

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 ?



richard.york October 13th, 2004 07:12 AM

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

elisabeth October 13th, 2004 09:06 AM

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">



All times are GMT -4. The time now is 01:47 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.