css print styles conflict with javascript precedence

M

Michael Repucci

Hi all, minor newbie problem I hope you can help with, since I can't
find the topic covered on line.

Basically, I have a div section in my xhtml that I want visible for
print (div {display: block;} in my print css), and visible if somebody
has javascript disabled (therefore also div {display: block;} in my
screen css), but not visible on screen with javascript activated
(i.e., turned off in javascript with div.style.display = "none").

The problem is one of precedence. When displaying the page on screen I
want my non-interactive javascript code to execute after the css rules
have been applied (so I put my javascript within window.onload). But
when a user attempts to print, I'd prefer if the css (for print) were
applied after the javascript. Unfortunately this doesn't seem to be
what happens.

What should I do?
 
M

Michael Repucci

Problem solved... at least for recent browsers. I forgot about the
CSS !important directive. Adding that gives the desired effect.
 

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

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top