Print without ads

M

Mike S.

My website is a free one that places ads on the top of the web page.
Is there a way to provide a print option so that users can print the
pages without the ads?
 
D

David Dorward

My website is a free one that places ads on the top of the web page.
Is there a way to provide a print option so that users can print the
pages without the ads?

Since your agreement with your hosting provider almost certainly
forbids removing the adverts, it is very likely that your only
reasonable option is to switch to better hosting.
 
D

dorayme

David Dorward said:
Since your agreement with your hosting provider almost certainly
forbids removing the adverts, it is very likely that your only
reasonable option is to switch to better hosting.

I had thought, in my reply, it was ok to include a print style
sheet but, of course (!), this is probably unlikely to work on
such hosting.
 
B

Bergamot

dorayme said:
I had thought, in my reply, it was ok to include a print style
sheet but, of course (!), this is probably unlikely to work on
such hosting.

Why do you say that? It seems very unlikely that such a server would be
clever enough to distinguish a print stylesheet from any other
stylesheet, especially since it's the browser, not the server, that
decides what rules to apply.
 
A

asdf

Mike S. said:
My website is a free one that places ads on the top of the web page.
Is there a way to provide a print option so that users can print the
pages without the ads?

Yes.

Create a CSS stylesheet thus in the <head> section (or put in a separate CSS
file if you so desire) thus:

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

Note 'media="print" attribute of the style tag. This is what allows you to
reformat your stuff for printing.

Give the ad (assuming it's an image) a classname like 'noprint' thus:

<img src='blah' alt='An ad.' class='noprint'>

You can extend this to remove lots of other stuff from your printout like
menus etc.... just wrap the stuff you don't want printed with a div of class
'noprint'.

Be warned... I haven't tried this on crusty browsers, but it works with
current releases of IE, FF and Opera.
 
D

dorayme

Bergamot said:
Why do you say that? It seems very unlikely that such a server would be
clever enough to distinguish a print stylesheet from any other
stylesheet, especially since it's the browser, not the server, that
decides what rules to apply.

I said it because DD brought further to my attention that it was
a free web hosting service, and while his point might have been a
legal one, I then went on to think they would likely make
technical provisions to stop any different stylesheet from
operating to avoid their ads. I have a couple of barely used free
service and they quite often override various things I have
tried, perhaps there are cleverer ways of doing things that
escaped me.

But you make me regret the craven appearance of my retraction. My
enemies, and there are many, can take advantage of this.

Anyway, I just had a thought, as crisp in its novelty as it is
chilly this fine morning in Sydney, the proof is in the pudding,
OP might consider trying it and seeing what happens when he/she
prints and then, if all goes well, seeing if any letter from any
solicitor comes in the post or worse, several large thugs on the
doorstep.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top