document.all and css

S

Stuart Wexler

Hi,

I'm attempting to loop through the document.all collection of a page to make
universal height, width, size changes. I am doing this on a page with a
relative link to a css style sheet. In testing this out, I notice that it
registers the DIV tags and such, but for some reason, it won't recognize any
of the attributes of those DIV tags possibly because the styles are dictated
by the .css file. Is there any way javascript can recognize style
properties set by a separate style sheet?

Thanks.
 
R

Richard Cornford

Stuart Wexler said:
I'm attempting to loop through the document.all collection of a
page to make universal height, width, size changes. I am doing
this on a page with a relative link to a css style sheet. In
testing this out, I notice that it registers the DIV tags and
such, but for some reason, it won't recognize any of the attributes
of those DIV tags possibly because the styles are dictated by the
.css file. Is there any way javascript can recognize style
properties set by a separate style sheet?

The - style - objects of HTML elements initially only hold CSS style
settings from inline style attributes on those elements. On IE 5.0+ HTML
elements also have a - currentStyle - object from which the current
settings for most CSS values for an element can be read.

Gecko browsers have a window.getComputedStyle method that can provide
some similar information for those browsers, but if you are using
document.all to loop through the elements that will not be relevant.

Richard.
 
S

Stuart Wexler

Thanks. Now I have a second question. What I'm basically doing is trying
to ratio out font sizes, widths and heights according to the screen
resolution property. So I have the ideal resolution, get the actual
resolution, and get a ratio. I then want to multiply things like .left by
the width ratio, and fontsize by the height ratio. But the problem is that
these measurements are treated often as strings so a.left = a.left * ratio
doesn't work. Any ideas as to how to resolve that?
 
R

Richard Cornford

... . Changing the font size for the BODY could
scale the entire content in one operation.
<snip>

Thinking about it some more, if the page is only going to be sized once
you could leave the DOM alone and just document.write a STYLE tag into
the page as it loads that includes a specification for the BODY
font-size (overriding a default set in the CSS style sheet) and let the
rest of the document inherit from that.

<script type="text/javascript">
document.write('<style type="text/css">\nBODY {font-size:'+
size+
'%;}\n<\/style>');
</script>

Though, as Randy pointed out, you may still be tripped up by user style
sheet setting, but using relative CSS units throughout the rest of the
document should (may) still leave the viewer with approximately what you
intended, at least as far as the overall layout goes.

Richard.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top