473,549 Members | 5,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3195
"Stuart Wexler" <St*******@comc ast.net> wrote in message
news:HC******** ************@co mcast.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.getCompu tedStyle 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*****@litote s.demon.co.uk> wrote in message
news:be******** ***********@new s.demon.co.uk.. .
"Stuart Wexler" <St*******@comc ast.net> wrote in message
news:HC******** ************@co mcast.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.getCompu tedStyle 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************ ********@comcas t.com>, "Stuart Wexler"
<St*******@comc ast.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*****@litote s.demon.co.uk> wrote in message
news:be******** ***********@new s.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
2861
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();'>"); document.write("<OPTION VALUE='0.345066110642241'>Argentina Peso </OPTION>"); document.write("<OPTION VALUE='0.790200069503053'>Australia Dollar
2
2372
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 copying/pasting everytime I change it, I figure this will be better, as I only change it once. The problem is, document.write doesn't handle multiple...
2
1668
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. This is working fine for tables of this size. Unfortunately, my app produces lots of considerably bigger tables and the 'toggle' can take over a...
1
2692
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 working, but it only worked for IE. You can see a working version here: http://www.publicpen.com/designer/mcControlPanel.php username: designer...
12
10135
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 scrollbar, you get the height of the entire document, screwing up any chance of centering a window in the browser using these values. Is there a...
4
5452
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) { document.getElementById(nameOfDiv).style.visibility='visible'; document.getElementById(nameOfDiv).style.height='auto'; if (nameOfDiv != 'weblogs')
5
2945
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 the tab key when the down arrow key is pressed. (we know there are other way to control focus flow but we use a lot of dynamic jsp fields, that will...
6
3361
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 properties with this script: function checkform(btntype) {
4
2614
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 iframe's src property. Being that IE does not follow standard and considers an id, name, etc as a qualifying identifier for the document.getElementById...
0
7526
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7723
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7962
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7480
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7814
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5373
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.