473,378 Members | 1,416 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

document.all and css

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
4 3190
"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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: techy techno | last post by:
Hii Just wanted to know how can I decorate my texboxes and Listmenu which is called from a JS file using the following code below: document.write("<SELECT NAME='cur2' ONCHANGE='cconv1();'>");...
2
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of...
2
by: Edward | last post by:
The below code builds 2 tables 4 rows by 4 cols. All cells have checkboxes. When checked, the checkboxes in the first column automatically check the remainder of the check boxes in the same row. ...
1
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff...
12
by: Kepler | last post by:
How do you get the height of the client browser in IE? Both document.body.clientHeight and document.body.offsetHeight return the height of the document. If the page is long and there's a vertical...
4
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) {...
5
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate...
6
by: therig | last post by:
I'm having issues, I've spent many hours searching and I'm a noob at javascript, any help will be greatly appreciated. I keep getting the following error: Error: document.forms.sec11_A has no...
4
by: dr1ft3r | last post by:
Hey guys, I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.