?
Solved

@media in JSP page

Posted on 2006-07-08
9
Medium Priority
?
674 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
6 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
Technology Partners: 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 400 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

809 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