Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 6th, 2004, 09:34 AM
Authorized User
 
Join Date: Feb 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

Reply With Quote
  #2 (permalink)  
Old October 6th, 2004, 04:17 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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 ;)
Reply With Quote
  #3 (permalink)  
Old October 7th, 2004, 02:47 AM
Authorized User
 
Join Date: Feb 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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




Reply With Quote
  #4 (permalink)  
Old October 7th, 2004, 05:43 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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 ;)
Reply With Quote
  #5 (permalink)  
Old October 7th, 2004, 07:54 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

> 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
Reply With Quote
  #6 (permalink)  
Old October 7th, 2004, 08:07 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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 ;)
Reply With Quote
  #7 (permalink)  
Old October 8th, 2004, 06:46 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

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
Reply With Quote
  #8 (permalink)  
Old October 13th, 2004, 04:49 AM
Authorized User
 
Join Date: Feb 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 ?


Reply With Quote
  #9 (permalink)  
Old October 13th, 2004, 07:12 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

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
Reply With Quote
  #10 (permalink)  
Old October 13th, 2004, 09:06 AM
Authorized User
 
Join Date: Feb 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to print image at center of paper EXACTLY guntank C# 2005 1 September 24th, 2006 04:43 AM
Print Button itHighway Classic ASP Basics 2 February 27th, 2005 05:48 PM
'print' button crmpicco Classic ASP Basics 0 February 8th, 2005 09:25 AM
print button alitoday Classic ASP Basics 1 June 5th, 2004 05:01 AM
print out on a paper hosefo81 PHP How-To 4 February 11th, 2004 03:58 PM



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


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