Welcome to WebmasterWorld Guest from 54.226.23.160

Forum Moderators: open

Message Too Old, No Replies

How to prevent floating ad player from printing in IE7?

     
10:35 am on Mar 28, 2008 (gmt 0)

New User

10+ Year Member

joined:Jan 31, 2006
posts: 31
votes: 0


On the side of my page I have a floating ad player that uses javascript. It expands and plays a commercial at certain times of the day. When an ad isn't playing the player is just a small bar on the side of the screen. If I'm using firefox and print the page, the player (bar on side of screen) doesn't print out. It does, however, when using IE7. Any ideas on how to prevent it printing? I am using a print style sheet with img {display: none !important;}
3:10 pm on Mar 28, 2008 (gmt 0)

Preferred Member

10+ Year Member

joined:July 5, 2005
posts:352
votes: 0


Your best bet is hide the player using CSS;

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

In your css file make a class that hides elements, like this;
.hide4print{ display:none }

And then just assign that class to your player (or any other element you don't want to appear on paper).

3:13 pm on Mar 28, 2008 (gmt 0)

Preferred Member

10+ Year Member

joined:July 5, 2005
posts:352
votes: 0


I really have no idea how I missed your last sentence saying you already use a print style sheet. My bad.

Still, is your ad player an image? Your css is only hiding images.

11:53 pm on Mar 28, 2008 (gmt 0)

New User

10+ Year Member

joined:Jan 31, 2006
posts: 31
votes: 0


Currently, I don't have an external CSS file. I have my print style sheet like this:

<style type="text/css" media="print">
.noprint {display:none;}
img {display: none !important;}
a {text-decoration: none; color:000;}
</style>

I'm not sure whether this is equivalent to your suggestion Trace, but I tried placing <span class="noprint"> </span> around the ad player code. Unfortunately, the ad player still prints out.

7:28 am on Mar 29, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 5, 2004
posts:46
votes: 0


is it possible to default it to render offscreen somehow or below another element on the page and only have it appear when its playing something? not sure of what you mean based on what you've said.

Sample code greatly helps understand whats going on - if you can please post some.

6:17 pm on Mar 29, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


I tried placing <span class="noprint"> </span> around the ad player code.

Spans are inline elements. Try a DIV or some other block element.

11:17 pm on Mar 29, 2008 (gmt 0)

New User

10+ Year Member

joined:Jan 31, 2006
posts: 31
votes: 0


I did try placing <div id="myinclude"> </div> around the two pieces of code I was given by the ad company, and then adding #myinclude {display: none;} to my print style sheet as follows

<style type="text/css" media="print">
.noprint {display:none;}
#myinclude {display:none;}
img {display: none !important;}
a {text-decoration: none; color:000;}
</style>

The ad player still printed in IE7.

However, thanks to SuzyUK, the problem is now fixed.

In the generated source code (something I only learned about today), there were div ids, img ids and iframe ids. I mentioned the specific names of each in the print style sheet as follows

<style type="text/css" media="print">
.noprint {display:none;}
#ABDIV, #ABIMG {visibility: hidden !important; display: none !important; }
img {display: none !important;}
a {text-decoration: none; color:000;}
</style>

Now the player doesn't print in IE7, and it is no longer interacting with IE7's default "Shrink to Fit" and causing my pages to print with tiny font.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members