Solved

@media in JSP page

Posted on 2006-07-08
9
565 Views
Last Modified: 2010-05-18
I’m trying to use CSS to apply printer-friendly feature for different pages in my web sit but the problem is when I apply that CSS by using @media or <link element and media=”print” attribute; it seems like that changes are applying directly to my web page not only on printer-friendly page for example if I put this line
<div align="right" ><a href="javascript:Clickheretoprint()" id="TopLayer"> Click here to print</a>    </div>
in my jsp page the line will never appear in my page itself :(

Notice: I have this id in CSS
#TopLayer
{
display:none;
}

Any help please?
0
Comment
Question by:ocmara
  • 3
  • 2
9 Comments
 
LVL 4

Expert Comment

by:Meritor
ID: 17064762
you made display:none; how can you except that it would appear in your page.

0
 
LVL 3

Expert Comment

by:mdg12
ID: 17066879
Meritor -- If you specify a medium for a section of CSS, those styles will only apply to the specified medium...  So the css within a "printer" section does not apply to the browser version

Are you sure there are no other non-print css tags that are causing the link to be hidden?   If you include the entire source I can help debug.

There are 4 ways to specify the media...  
1) For inline styles
<style type="text/css" media="print">
#toplayer {
...
}
</style>

2) With an external css file
<link type="text/css" rel="stylesheet" href="style.css" media="print" />

3) With an external css file (my preference over #2)
<style type="text/css" media="print">
@import 'style.css';
</style>

4) within a non-media-specific style set, that has a section for printable attributes
<style type="text/css">
#toplayer {
/*common attributes*/
}
@media print {
    #toplayer {
        display:none;
    }
}
</style>


Hope this helps!
0
 

Author Comment

by:ocmara
ID: 17067216
It still applies every thinks in print media section over web page still. That happen with all deferent way of specifies the print media.
I worked with WDK component, any advice!!!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:mdg12
ID: 17067860
Can you give a link to the actual page, or more source code so we can see what is going wrong?
0
 

Author Comment

by:ocmara
ID: 17070713
in JSP page there is

<html>
<head><dmf:webform/></head>

<body>

<table align='center'>
    <div align="right" ><a href="javascript:self.print()" id="toplayer"> Click here to print</a>    </div>
   <tr><td align=left class='SHeading'>Print Friendly</td></tr>
</table>
</body>
</html>
 
And in a separated XML file I point to that CSS and it work fine regardless to print media. FYI:I use component approach.
0
 
LVL 3

Accepted Solution

by:
mdg12 earned 100 total points
ID: 17072150
One problem is that you should never put a <div> directly inside a <table>..  You can move it outside the table, or put it inside a <td>

Try this:
<html>
<head><dmf:webform/></head>
<body>
<div align="right" ><a href="javascript:self.print()" id="toplayer"> Click here to print</a>    </div>
<table align='center'>
   <tr><td align=left class='SHeading'>Print Friendly</td></tr>
</table>
</body>
</html>
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question