By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

document.all and css

P: n/a
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.
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Stuart Wexler" <St*******@comcast.net> wrote in message
news:HC********************@comcast.com...
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.
--

Example JavaScript DOM listings for: Opera 7.11,
Mozilla 1.2 and ICEbrowser 5.4
<URL: http://www.litotes.demon.co.uk/dom_root.html >
Jul 20 '05 #2

P: n/a
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?
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:be*******************@news.demon.co.uk...
"Stuart Wexler" <St*******@comcast.net> wrote in message
news:HC********************@comcast.com...
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.
--

Example JavaScript DOM listings for: Opera 7.11,
Mozilla 1.2 and ICEbrowser 5.4
<URL: http://www.litotes.demon.co.uk/dom_root.html >

Jul 20 '05 #3

P: n/a
In article <sr********************@comcast.com>, "Stuart Wexler"
<St*******@comcast.net> writes:
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?


parseInt and parseFloat
Or, unary + operator.

But, in IE, the user can explicitly tell it to ignore your definitions. And
also change the sizes without the webpage every knowing it. But my screen
resolution is totally irrelevant to font sizes. As is my browser window size. I
prefer reading webpages in about a 14 point font and its set that way. Nothing
you do in Javascript will change that size either.
--
Randy
All code posted is dependent upon the viewing browser
supporting the methods called, and Javascript being enabled.
Jul 20 '05 #4

P: n/a
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:be*******************@news.demon.co.uk...
<snip>
... . 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.
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.