473,804 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to read CSS styles - problem

I seem to remember being able to do this, but I can't seem to find out
how I did it before...

Basically, I have styles defined by class in a stylesheet, and I need
to read the "width" style. obj.currentStyl e.width works just fine in
IE, but Firefox doesn't recognize it.
document.defaul tView.getComput edStyle(obj,nul l).getPropertyV alue('width')
gives me the actual width (just as obj.offsetWidth does), not the width
style assigned by the stylesheet.

Because the elements are cells in a table row, the rendering of the
table is causing the actual width to vary from the assigned width
style. So, how can I get the assigned width style in Firefox (and other
browsers)?

Or am I out of luck on this?

Dec 14 '05 #1
2 1886
Tony wrote:
Basically, I have styles defined by class in a stylesheet, and I need
to read the "width" style. obj.currentStyl e.width works just fine in
IE, but Firefox doesn't recognize it.
Because it is IE-proprietary.
document.defaul tView.getComput edStyle(obj,nul l).getPropertyV alue('width')
AFAIS document.defaul tView refers to the same object as `window' and is not
more or less standards compliant (than the latter proprietary property of
the Global Object.)
gives me the actual width (just as obj.offsetWidth does), not the width
style assigned by the stylesheet.

Because the elements are cells in a table row, the rendering of the
table is causing the actual width to vary from the assigned width
style.
Why is that a problem?

ISTM that you have a design problem. Why are you forcing the cells to
a specific width in the first place? Let the UA do its job to compute
what is the appropriate width according to their content and the actual
viewport (or layout box) size.
So, how can I get the assigned width style in Firefox (and other
browsers)?
Retrieve the value of the `className' property of the element and
search through the `cssRules' collection of each element of the
document.styleS heets collection. (You do not want to do that.)
Or am I out of luck on this?


No, but support is still limited, and the approach is rather inefficient.
It is far better to resolve your design problem by reconsidering your
approach.
PointedEars
Dec 15 '05 #2
Thomas 'PointedEars' Lahn wrote:
Tony wrote:
Basically, I have styles defined by class in a stylesheet, and I need
to read the "width" style. obj.currentStyl e.width works just fine in
IE, but Firefox doesn't recognize it.


Because it is IE-proprietary.


I figured as much
document.defaul tView.getComput edStyle(obj,nul l).getPropertyV alue('width')


AFAIS document.defaul tView refers to the same object as `window' and is not
more or less standards compliant (than the latter proprietary property of
the Global Object.)


OK - I got that from Quirksmode, I usually find PPK to be reasonably
reliable on the compliance matters, but he admitted that script left
something to be desired.
gives me the actual width (just as obj.offsetWidth does), not the width
style assigned by the stylesheet.

Because the elements are cells in a table row, the rendering of the
table is causing the actual width to vary from the assigned width
style.


Why is that a problem?

ISTM that you have a design problem. Why are you forcing the cells to
a specific width in the first place? Let the UA do its job to compute
what is the appropriate width according to their content and the actual
viewport (or layout box) size.


Easy enough to say, but when the boss says "I want things to happen
this way", you do it.

Believe it or not, we do have reasons for what we're doing - even if it
may not seem that way by some of the questions I ask :)
So, how can I get the assigned width style in Firefox (and other
browsers)?


Retrieve the value of the `className' property of the element and
search through the `cssRules' collection of each element of the
document.styleS heets collection. (You do not want to do that.)


I wound up doing something similar, but not exactly like that. It does
what I need, though. I was hoping there might be a somewhat more
elegant solution.
Or am I out of luck on this?


No, but support is still limited, and the approach is rather inefficient.
It is far better to resolve your design problem by reconsidering your
approach.


Given the nature of the task, that really can't be done.

Thanx for the input.

Dec 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1989
by: Quinton | last post by:
I'm running a website that uses CSS to format the text and a CGI program Coranto that icludes news updates via SSI. My problem is that some parts of the CSS don't seem to take effect on the included news. All four link styles are used, and all four work in the included text files. The text styles, on the other hand, seem not to work at all. The text that's part of the actual HTML file is formated according to the CSS codes. However, the...
2
1671
by: christian | last post by:
I am having a recurring problem with a specific css stylesheet. For no evident reason, seemingly random styles (though from the same area of the stylesheet) are selectively ignored by browsers. Cutting the ignored style and pasting it to the top of the stylesheet solves the problem, but then a few weeks later, other styles are not being recognised. What could be causing this problem? Is it to do with the length of the document? Has anyone...
7
6847
by: codeslayer | last post by:
Greetings to everyone in ‘forum-land': I have a problem that has plaguing me to no end. It is a CSS-related question, and I have not seen this question posted anywhere in forums or through Google search. So here is my problem: I want to use CSS to apply images as bullet styles. However, I want to be able to apply VARIOUS, MULTIPLE styles in the same document. For example, let's assume I have a set of categorized hyperlinks on a...
12
2581
by: dan.vendel | last post by:
Hi, I know nothing about javascript, but quite a lot about regulat html and CSS. Have bumped into a problem that people in this fine congregation perhaps can help me with. I'm making a webshop. When user eventually ends up at the credit card processor's secure pages, the styles are quite different from the actual site's. I have managed to change some basics through a control
0
4708
by: Peter | last post by:
I am having a problem reading an Excel file that is XML based. The directory I am reading contains Excel files that can be of two types. Either generic Microsoft based or XML based. I am reading the Microsoft based files with an OleDbDataAdapter. Then filling the contents of the first worksheet into a dataset. However when I try to add the XML based file to my dataset using an XmlTextReader I can never seem to get it to save to a...
2
1713
by: Billy Cousins | last post by:
Can anyone tell me how to programmatically read the values from a stylesheet that is linked into my asp.net app? I can read styles that are declared in the HTML code, but have not found a way to get to the external stylesheet. For example, I want to read the font-size and font-family from a class in the stylesheet.
5
4788
by: MLM450 | last post by:
I want to use visual styles in my app, but it is causing a problem with a DLL I use. Is there a way to disable visual styles for that DLL? I do not have access to the code for the DLL. The DLL's developer is aware of the problem but will not have a fix ready in time for me.
1
4118
by: Marc Bartsch | last post by:
Hi, My C# app throws the following exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. From what I read so far I found that the problem can be connected to P/Invoke and that the places at which this exception is thrown might not reflect the actual problem. In my case, the exception is thrown, when I try to minimise my main window to the system...
4
2714
by: splounx | last post by:
Hi there, I am a relative CSS & JavaScript novice and I have a particular problem that is beyond my level of knowledge so I thought I'd tap the collective wisdom of this group. I would like to know if there is a means of writing JavaScript that will dynamically display the styles which are currently applied to any DOM element on a web page ( i.e., those applied by ID, those applied by class, etc.) as the user moves their mouse over...
0
9712
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10343
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9171
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7634
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5530
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4308
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
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.