navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

css content in the stylesheet?

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> Cascading Style Sheets >> css content in the stylesheet?
Page: [1]
 
mtfm

 

Posts: 414
Joined: 1/13/2006
From: Mesa, AZ
Status: offline

 
css content in the stylesheet? - 1/9/2007 19:19:05   
OK, I have a (dumb) question. I know it is probably not possible, but I'm going to ask anyway.


I have a website with several alternate stylesheets set up, one for printing. I'd like to insert a snippet of code saying "this page was printed on..." onto each page whenever it is printed. I was wondering if I could insert that code into the stylesheet.

I know this is heresy, since the whole point is to seperate style and content and this would be muddying things up-- but each page in the site already has a "last modified on" date, and inserting the code into the page itself will mess up that date. That date is as important if not more so than the printed date....




womble

 

Posts: 5461
Joined: 3/14/2005
From: Living on the edge
Status: offline

 
RE: css content in the stylesheet? - 1/9/2007 19:28:57   
The only way I can think to do it is to put both on the page but then use the stylesheets to control which is visible/printed, for example you could something like:

On the normal screen stylesheet:

#modifieddate { whatever styles }
#printeddate { display: none; }

...and then on the print stylesheet:

#modifieddate { display: none; }
#printeddate { whatever styles }

_____________________________

~~ "A cruel god ain't no god at all" ~~
:)

(in reply to mtfm)
mtfm

 

Posts: 414
Joined: 1/13/2006
From: Mesa, AZ
Status: offline

 
RE: css content in the stylesheet? - 1/9/2007 19:33:20   
yeah, that's about what I came up with. But as I say I don't want to modify the pages themselves (and mess up the modified dates). That's why I want to do it entirely within the stylesheets and not touch the pages themselves.

As I say I expect this is not possible-- but have been surprised before. :)

(in reply to womble)
womble

 

Posts: 5461
Joined: 3/14/2005
From: Living on the edge
Status: offline

 
RE: css content in the stylesheet? - 1/9/2007 20:08:23   
As far as I'm aware, the only thing you can put in stylesheets is styles (although I did read something recently about process CSS as PHP - can't remember in what context though so that's not much help! :))

What do you mean "mess up the modified dates"? What are you using to get the modified date - JavaScript/PHP/ASP?

Whatever you're using for the modified date, you'd use a separate function for the printed date, basically the current date -

date() in PHP,

... in JS you could use:
<p>Date printed: 
<script type="text/javascript">
<!--
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
document.write(month + "/" + day + "/" + year)
//-->
</script>
</p>


And in ASP: <%=month(date)%>/<%=day(date)%>/<%=year(date)%>

_____________________________

~~ "A cruel god ain't no god at all" ~~
:)

(in reply to mtfm)
rubyaim

 

Posts: 757
Joined: 6/22/2005
Status: offline

 
RE: css content in the stylesheet? - 1/9/2007 21:00:51   
mtfm, do you mean that if the pages are edited to include the printed date, the modified date will change, and not be a true reflection of the content modification?

Like Womble, I can't see how you would do this without using script, but it's an interesting question.

A workaround might be to add a note using :after to warn users to check the modification date - see code below (view it with FF or Opera). AFAIK this will not work in IE, so it is probably not very useful at all in the real world, but it is fun to play with :)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
<title>Body after print test</title>

<style type="text/css">

@media print {

body:after {
    content: "Please note the modified date of this document.";
    display: block;
    margin-top: 2em;
    text-align: right;
    font-weight: bold;
}
}

</style>

</head>

<body>

<h1>Print Preview this page.</h1>

<p>This is a test.  Look to the lower right of this paragraph on print preview.</p>
</body>

</html>



FWIW, I think the default printer setting on browsers will include the date printed in the footer, so the print date will show unless a user has removed this. Most users don't change these settings.


_____________________________

Sally

(in reply to womble)
womble

 

Posts: 5461
Joined: 3/14/2005
From: Living on the edge
Status: offline

 
RE: css content in the stylesheet? - 1/10/2007 5:27:09   

quote:

ORIGINAL: rubyaim

mtfm, do you mean that if the pages are edited to include the printed date, the modified date will change, and not be a true reflection of the content modification?



Ah! I see what you mean! I'd not thought of that! :)



_____________________________

~~ "A cruel god ain't no god at all" ~~
:)

(in reply to rubyaim)
jaybee

 

Posts: 13959
Joined: 10/7/2003
From: Berkshire, UK
Status: offline

 
RE: css content in the stylesheet? - 1/10/2007 8:23:46   
I understand it is possible to put javascript in the css file. DOn't ask me how though, I've only tried it once for a hack for IE and it doesn't validate so I took it out.

_____________________________

If it ain't broke..... fix it until it is.
:)

:)
GAWDS
Now where did I put that Doctype?

(in reply to womble)
Donkey

 

Posts: 3842
Joined: 11/13/2001
From: Blackfield United Kingdom
Status: offline

 
RE: css content in the stylesheet? - 1/10/2007 11:29:35   
Why not put the cgi code for today's date into an include which is put inside a div on all pages. Then hide the div on all style sheets except the print one.

_____________________________

:)

I have a higher and grander standard of principle than George Washington. He could not lie; I can, but I won't.
Samuel Clemens

(in reply to jaybee)
Page:   [1]

All Forums >> Web Development >> Cascading Style Sheets >> css content in the stylesheet?
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts