PDA

View Full Version : Hiding a Print Command Text


Ben@WEBProp
06-23-2003, 05:50 PM
So I have this page with the command:

<a href="#" onclick="javascript:window.print();return false">Print This Page</a>

so that the user can print a document as it is seen on the screen. However, when they do this, they also see the words "Print This Page" on the print out. I was wondering if there is a command I could add that would make these words not print, but allow the rest of the document to print fine.

Thanks!

-Ben

sage45
06-23-2003, 07:29 PM
Two ways you could accomplish this:

1.) Using frames to embed the print command in one frame and the content to print in the other frame...

2.) When the user presses the print this link, the page is rebuilt without the print this link in a new window and that new window is then submitted to the printer...

-sage-

Ben@WEBProp
06-23-2003, 08:02 PM
The frames idea is a good one, but I already have a frames layout that would be difficult to work this idea into...
If you could take a look at the site that I'm making and let me know what you think the best solution would be...

The page site is http://www.webpropertiesinc.com
To get to the page I need help with, follow the nav bar to Residential<Broadmoor and click on the link of that page that says "view the floor plans". Let me know if you want to view the source code for any reason...right now i have the no right click script on, but I will take it off for a while if you need me to.

Also, feel free if you have some extra time in which you are bored out of your skull to browse the site and let me know of any developmental directions that I should be taking. I know that the content is not finished, but most of the skeletal work is. I uploaded it to the net so I could get help from the people here at CodingForums on various pages. But if you don't want to browse around, don't feel pressured, k?

Also, what would be the coding to open the page in a new window, automaticly print it, and then close that window when the user finalizes or cancels the printing? If you don't think that I should go that route, then don't supply the code.

Thanks a ton!

-Ben

kansel
06-23-2003, 08:38 PM
why not use media-specific stylesheets to disable display of the link when printed?

<style type="text/css" media="print">
.dontprintme { display: none; }
</style>

<a href="#" onclick="javascript:window.print();return false" class="dontprintme">Print This Page</a>

pardicity3
06-23-2003, 08:40 PM
Beat to the post...oh well, I have become used to it by now. And plus I was wrong, it's display: none; not display: hidden; duh!


You could specify a seperate Style Sheet and set it's media to print like so:

<link rel="stylesheet" href="printstyle.css" media="print" type="text/css" />

Then in that style sheet just hide the link by doing something like so:

a.printlink { display: none; }

That will get rid of the link only when the page is printed. Granted, it won't work on browsers that don't support CSS, but, by the looks of your site, you probably aren't expecting to many ancient browsers.

Ben@WEBProp
06-23-2003, 09:20 PM
Wow! Thanks! I got it to work! You are awesome!

Oh ya, I forgot to add something. Alright, so when I use that print command, it seems to print the banner (with nothing in it) and the target frame, but not the nav bar frame. So what I end up with when I print the page is a blank top 1/5 of a page, even on page 2, 3, 4, etc. Do I need to select a target frame? If so, how do I do that?

Also, what do you guys think of the site so far? Does it look somewhat professional with an appealing edge? Or is it totally the worst page that you have ever seen? Any comments or ideas would help alot before I do the "final" publishing. I will be updating it, but it would be great to have a finalized style.

I have no doubt that my last question will be laughed at by many, but what is a Style Sheet? I am truly a newbie to much of this lingo, as I mainly worked many years ago soley with HTML, and it was just for fun.

Thanks again! You guys rock!

-Ben