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

Access CSS with JavaScript

P: n/a
I have a css file this is a portion of it:

/* trackaccept.css */
div.track {
width:400px;
height: 100px;
}

I have this in my ASP page:

<link rel="stylesheet" type="text/css" href="/includes/trackaccept.css"/>

I need to read the values for width and height in my page. How do I acess those values using JavaScipt? Thanks.

I have a length of 2 for CSS objects so I don't know whether it is 0 or 1 I'm assuming 0.since I don't have any other external CSS statements. The other is declared in the page as <style></style>

--
George Hester
__________________________________
Jul 20 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a


George Hester wrote:
I have a css file this is a portion of it:

/* trackaccept.css */ div.track { width:400px; height: 100px; }

I have this in my ASP page:

<link rel="stylesheet" type="text/css"
href="/includes/trackaccept.css"/>

I need to read the values for width and height in my page. How do I
acess those values using JavaScipt? Thanks.

I have a length of 2 for CSS objects so I don't know whether it is 0
or 1 I'm assuming 0.since I don't have any other external CSS
statements. The other is declared in the page as <style></style>


Whether you have
<link rel="stylesheet"
or
<style type="text/css">
doesn't matter, browsers like IE4+ or Netscape 6+ and Mozilla support a
document.styleSheets
collection where each sheet appears.
You can access the CSS rules in the stylesheets and read and change
value of properties in a rule, unfortunately different in IE and
Netscape. IE has
document.styleSheets[i].rules[i].style.width
Netscape
document.styleSheets[i].cssRules[i].style.width

Here is an example:

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getStyleObject (styleSheetIndex, ruleIndex) {
if (document.styleSheets) {
var styleSheet = document.styleSheets[styleSheetIndex];
if (styleSheet) {
var rule;
if (styleSheet.cssRules) {
rule = styleSheet.cssRules[ruleIndex];
}
else if (styleSheet.rules) {
rule = styleSheet.rules[ruleIndex];
}
if (rule && rule.style) {
return rule.style;
}
else {
return null;
}
}
else {
return null;
}
}
else {
return null;
}
}

function testStyleSheet () {
var style = getStyleObject(0, 0);
if (style) {
alert('style.height: ' + style.height);
}
else {
alert('style not found.');
}
}
</script>
</head>
<body onload="testStyleSheet();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>

Note that even Opera 7 doesn't support document.styleSheets. And I don't
know about Safari or Konqueror support, does anyone else care to check
and contribute?

Of course with external style sheets make sure you use <body onload
before trying to access them.

You can also check the selector of a rule with selectorText:

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getStyleObjectFromSelector (selectorText) {
if (document.styleSheets) {
for (var i = document.styleSheets.length - 1; i >= 0; i--) {
var styleSheet = document.styleSheets[i];
var rules;
if (styleSheet.cssRules) {
rules = styleSheet.cssRules;
}
else if (styleSheet.rules) {
rules = styleSheet.rules;
}
if (rules) {
for (var j = rules.length - 1; j >= 0; j--) {
if (rules[j].selectorText == selectorText) {
return rules[j].style;
}
}
}
}
return null;
}
else {
return null;
}
}

function testStyleSheet () {
var selectors = ['#aDiv', '.someClass'];
for (var i = 0; i < selectors.length; i++) {
var selector = selectors[i];
var style = getStyleObjectFromSelector(selector);
if (style) {
alert('Selector ' + selector + ': style.height: ' + style.height);
}
else {
alert('No rule found for selector ' + selector);
}
}
}
</script>
</head>
<body onload="testStyleSheet();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>
Of course if you are looking for the computed style of an object there
is no need to read through style sheet rules, getComputedStyle allows
that with Mozilla and with Opera 7 and element.currentStyle with IE5+:

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getComputedStyleForElement (element, cssPropertyName) {
if (element) {
if (window.getComputedStyle) {
return window.getComputedStyle(element,
'').getPropertyValue(cssPropertyName.replace(/([A-Z])/g,
"-$1").toLowerCase());
}
else if (element.currentStyle) {
return element.currentStyle[cssPropertyName];
}
else {
return null;
}
}
else {
return null;
}
}

function getComputedStyleForId (elementId, cssPropertyName) {
if (document.getElementById) {
return
getComputedStyleForElement(document.getElementById (elementId),
cssPropertyName);
}
else {
return null;
}
}

function testComputedStyle () {
var ids = ['aDiv', 'aP'];
for (var i = 0; i < ids.length; i++) {
var cssValue = getComputedStyleForId(ids[i], 'backgroundColor');
if (cssValue === null) {
alert('Style background-color for id ' + ids[i] + ' not found.');
}
else {
alert('Computed style for background-color for id ' + ids[i] + '
is ' + cssValue);
}
}
}
</script>
</head>
<body onload="testComputedStyle();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>

Watch out for Netscape 7 and Opera 7 normalizing CSS values, for
instance color values are returned as rgb(r, g, b).
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

P: n/a
Oh Martin thanks for that.

--
George Hester
__________________________________
"Martin Honnen" <ma*******@yahoo.de> wrote in message news:3f********@olaf.komtel.net...


George Hester wrote:
I have a css file this is a portion of it:

/* trackaccept.css */ div.track { width:400px; height: 100px; }

I have this in my ASP page:

<link rel="stylesheet" type="text/css"
href="/includes/trackaccept.css"/>

I need to read the values for width and height in my page. How do I
acess those values using JavaScipt? Thanks.

I have a length of 2 for CSS objects so I don't know whether it is 0
or 1 I'm assuming 0.since I don't have any other external CSS
statements. The other is declared in the page as <style></style>


Whether you have
<link rel="stylesheet"
or
<style type="text/css">
doesn't matter, browsers like IE4+ or Netscape 6+ and Mozilla support a
document.styleSheets
collection where each sheet appears.
You can access the CSS rules in the stylesheets and read and change
value of properties in a rule, unfortunately different in IE and
Netscape. IE has
document.styleSheets[i].rules[i].style.width
Netscape
document.styleSheets[i].cssRules[i].style.width

Here is an example:

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getStyleObject (styleSheetIndex, ruleIndex) {
if (document.styleSheets) {
var styleSheet = document.styleSheets[styleSheetIndex];
if (styleSheet) {
var rule;
if (styleSheet.cssRules) {
rule = styleSheet.cssRules[ruleIndex];
}
else if (styleSheet.rules) {
rule = styleSheet.rules[ruleIndex];
}
if (rule && rule.style) {
return rule.style;
}
else {
return null;
}
}
else {
return null;
}
}
else {
return null;
}
}

function testStyleSheet () {
var style = getStyleObject(0, 0);
if (style) {
alert('style.height: ' + style.height);
}
else {
alert('style not found.');
}
}
</script>
</head>
<body onload="testStyleSheet();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>

Note that even Opera 7 doesn't support document.styleSheets. And I don't
know about Safari or Konqueror support, does anyone else care to check
and contribute?

Of course with external style sheets make sure you use <body onload
before trying to access them.

You can also check the selector of a rule with selectorText:

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getStyleObjectFromSelector (selectorText) {
if (document.styleSheets) {
for (var i = document.styleSheets.length - 1; i >= 0; i--) {
var styleSheet = document.styleSheets[i];
var rules;
if (styleSheet.cssRules) {
rules = styleSheet.cssRules;
}
else if (styleSheet.rules) {
rules = styleSheet.rules;
}
if (rules) {
for (var j = rules.length - 1; j >= 0; j--) {
if (rules[j].selectorText == selectorText) {
return rules[j].style;
}
}
}
}
return null;
}
else {
return null;
}
}

function testStyleSheet () {
var selectors = ['#aDiv', '.someClass'];
for (var i = 0; i < selectors.length; i++) {
var selector = selectors[i];
var style = getStyleObjectFromSelector(selector);
if (style) {
alert('Selector ' + selector + ': style.height: ' + style.height);
}
else {
alert('No rule found for selector ' + selector);
}
}
}
</script>
</head>
<body onload="testStyleSheet();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>


Of course if you are looking for the computed style of an object there
is no need to read through style sheet rules, getComputedStyle allows
that with Mozilla and with Opera 7 and element.currentStyle with IE5+:

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getComputedStyleForElement (element, cssPropertyName) {
if (element) {
if (window.getComputedStyle) {
return window.getComputedStyle(element,
'').getPropertyValue(cssPropertyName.replace(/([A-Z])/g,
"-$1").toLowerCase());
}
else if (element.currentStyle) {
return element.currentStyle[cssPropertyName];
}
else {
return null;
}
}
else {
return null;
}
}

function getComputedStyleForId (elementId, cssPropertyName) {
if (document.getElementById) {
return
getComputedStyleForElement(document.getElementById (elementId),
cssPropertyName);
}
else {
return null;
}
}

function testComputedStyle () {
var ids = ['aDiv', 'aP'];
for (var i = 0; i < ids.length; i++) {
var cssValue = getComputedStyleForId(ids[i], 'backgroundColor');
if (cssValue === null) {
alert('Style background-color for id ' + ids[i] + ' not found.');
}
else {
alert('Computed style for background-color for id ' + ids[i] + '
is ' + cssValue);
}
}
}
</script>
</head>
<body onload="testComputedStyle();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>

Watch out for Netscape 7 and Opera 7 normalizing CSS values, for
instance color values are returned as rgb(r, g, b).
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3

P: n/a
Hello again Matin. I tried the ComputedStyle one you gave. After fixing for line continuation issues in my newsreader I am getting undefined for both alerts. Is there something wrong with it? Here is what you had and what I put it to that is removing the line continuation issues.

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getComputedStyleForElement (element, cssPropertyName) {
if (element) {
if (window.getComputedStyle) {
return window.getComputedStyle(element,'').getPropertyVal ue(cssPropertyName.replace(/([A-Z])/g, "-$1").toLowerCase());
}
else if (element.currentStyle) {
return element.currentStyle[cssPropertyName];
}
else {
return null;
}
}
else {
return null;
}
}

function getComputedStyleForId (elementId, cssPropertyName) {
if (document.getElementById) {
return
getComputedStyleForElement(document.getElementById (elementId), cssPropertyName);
}
else {
return null;
}
}

function testComputedStyle () {
var ids = ['aDiv', 'aP'];
for (var i = 0; i < ids.length; i++) {
var cssValue = getComputedStyleForId(ids[i], 'backgroundColor');
if (cssValue === null) {
alert('Style background-color for id ' + ids[i] + ' not found.');
}
else {
alert('Computed style for background-color for id ' + ids[i] + ' is ' + cssValue);
}
}
}
</script>
</head>
<body onload="testComputedStyle();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>

--
George Hester
__________________________________
"Martin Honnen" <ma*******@yahoo.de> wrote in message news:3f********@olaf.komtel.net...


George Hester wrote:
I have a css file this is a portion of it:

/* trackaccept.css */ div.track { width:400px; height: 100px; }

I have this in my ASP page:

<link rel="stylesheet" type="text/css"
href="/includes/trackaccept.css"/>

I need to read the values for width and height in my page. How do I
acess those values using JavaScipt? Thanks.

I have a length of 2 for CSS objects so I don't know whether it is 0
or 1 I'm assuming 0.since I don't have any other external CSS
statements. The other is declared in the page as <style></style>


Whether you have
<link rel="stylesheet"
or
<style type="text/css">
doesn't matter, browsers like IE4+ or Netscape 6+ and Mozilla support a
document.styleSheets
collection where each sheet appears.
You can access the CSS rules in the stylesheets and read and change
value of properties in a rule, unfortunately different in IE and
Netscape. IE has
document.styleSheets[i].rules[i].style.width
Netscape
document.styleSheets[i].cssRules[i].style.width

Here is an example:

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getStyleObject (styleSheetIndex, ruleIndex) {
if (document.styleSheets) {
var styleSheet = document.styleSheets[styleSheetIndex];
if (styleSheet) {
var rule;
if (styleSheet.cssRules) {
rule = styleSheet.cssRules[ruleIndex];
}
else if (styleSheet.rules) {
rule = styleSheet.rules[ruleIndex];
}
if (rule && rule.style) {
return rule.style;
}
else {
return null;
}
}
else {
return null;
}
}
else {
return null;
}
}

function testStyleSheet () {
var style = getStyleObject(0, 0);
if (style) {
alert('style.height: ' + style.height);
}
else {
alert('style not found.');
}
}
</script>
</head>
<body onload="testStyleSheet();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>

Note that even Opera 7 doesn't support document.styleSheets. And I don't
know about Safari or Konqueror support, does anyone else care to check
and contribute?

Of course with external style sheets make sure you use <body onload
before trying to access them.

You can also check the selector of a rule with selectorText:

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getStyleObjectFromSelector (selectorText) {
if (document.styleSheets) {
for (var i = document.styleSheets.length - 1; i >= 0; i--) {
var styleSheet = document.styleSheets[i];
var rules;
if (styleSheet.cssRules) {
rules = styleSheet.cssRules;
}
else if (styleSheet.rules) {
rules = styleSheet.rules;
}
if (rules) {
for (var j = rules.length - 1; j >= 0; j--) {
if (rules[j].selectorText == selectorText) {
return rules[j].style;
}
}
}
}
return null;
}
else {
return null;
}
}

function testStyleSheet () {
var selectors = ['#aDiv', '.someClass'];
for (var i = 0; i < selectors.length; i++) {
var selector = selectors[i];
var style = getStyleObjectFromSelector(selector);
if (style) {
alert('Selector ' + selector + ': style.height: ' + style.height);
}
else {
alert('No rule found for selector ' + selector);
}
}
}
</script>
</head>
<body onload="testStyleSheet();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>


Of course if you are looking for the computed style of an object there
is no need to read through style sheet rules, getComputedStyle allows
that with Mozilla and with Opera 7 and element.currentStyle with IE5+:

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getComputedStyleForElement (element, cssPropertyName) {
if (element) {
if (window.getComputedStyle) {
return window.getComputedStyle(element,
'').getPropertyValue(cssPropertyName.replace(/([A-Z])/g,
"-$1").toLowerCase());
}
else if (element.currentStyle) {
return element.currentStyle[cssPropertyName];
}
else {
return null;
}
}
else {
return null;
}
}

function getComputedStyleForId (elementId, cssPropertyName) {
if (document.getElementById) {
return
getComputedStyleForElement(document.getElementById (elementId),
cssPropertyName);
}
else {
return null;
}
}

function testComputedStyle () {
var ids = ['aDiv', 'aP'];
for (var i = 0; i < ids.length; i++) {
var cssValue = getComputedStyleForId(ids[i], 'backgroundColor');
if (cssValue === null) {
alert('Style background-color for id ' + ids[i] + ' not found.');
}
else {
alert('Computed style for background-color for id ' + ids[i] + '
is ' + cssValue);
}
}
}
</script>
</head>
<body onload="testComputedStyle();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>

Watch out for Netscape 7 and Opera 7 normalizing CSS values, for
instance color values are returned as rgb(r, g, b).
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #4

P: n/a
Oh I got it never mind it was anothe line continuation issue.

--
George Hester
__________________________________
"George Hester" <he********@hotmail.com> wrote in message news:ta********************@twister.nyroc.rr.com.. .
Hello again Matin. I tried the ComputedStyle one you gave. After fixing for line continuation issues in my newsreader I am getting undefined for both alerts. Is there something wrong with it? Here is what you had and what I put it to that is removing the line continuation issues.

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getComputedStyleForElement (element, cssPropertyName) {
if (element) {
if (window.getComputedStyle) {
return window.getComputedStyle(element,'').getPropertyVal ue(cssPropertyName.replace(/([A-Z])/g, "-$1").toLowerCase());
}
else if (element.currentStyle) {
return element.currentStyle[cssPropertyName];
}
else {
return null;
}
}
else {
return null;
}
}

function getComputedStyleForId (elementId, cssPropertyName) {
if (document.getElementById) {
return
getComputedStyleForElement(document.getElementById (elementId), cssPropertyName);
}
else {
return null;
}
}

function testComputedStyle () {
var ids = ['aDiv', 'aP'];
for (var i = 0; i < ids.length; i++) {
var cssValue = getComputedStyleForId(ids[i], 'backgroundColor');
if (cssValue === null) {
alert('Style background-color for id ' + ids[i] + ' not found.');
}
else {
alert('Computed style for background-color for id ' + ids[i] + ' is ' + cssValue);
}
}
}
</script>
</head>
<body onload="testComputedStyle();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>

--
George Hester
__________________________________
"Martin Honnen" <ma*******@yahoo.de> wrote in message news:3f********@olaf.komtel.net...


George Hester wrote:
I have a css file this is a portion of it:

/* trackaccept.css */ div.track { width:400px; height: 100px; }

I have this in my ASP page:

<link rel="stylesheet" type="text/css"
href="/includes/trackaccept.css"/>

I need to read the values for width and height in my page. How do I
acess those values using JavaScipt? Thanks.

I have a length of 2 for CSS objects so I don't know whether it is 0
or 1 I'm assuming 0.since I don't have any other external CSS
statements. The other is declared in the page as <style></style>


Whether you have
<link rel="stylesheet"
or
<style type="text/css">
doesn't matter, browsers like IE4+ or Netscape 6+ and Mozilla support a
document.styleSheets
collection where each sheet appears.
You can access the CSS rules in the stylesheets and read and change
value of properties in a rule, unfortunately different in IE and
Netscape. IE has
document.styleSheets[i].rules[i].style.width
Netscape
document.styleSheets[i].cssRules[i].style.width

Here is an example:

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getStyleObject (styleSheetIndex, ruleIndex) {
if (document.styleSheets) {
var styleSheet = document.styleSheets[styleSheetIndex];
if (styleSheet) {
var rule;
if (styleSheet.cssRules) {
rule = styleSheet.cssRules[ruleIndex];
}
else if (styleSheet.rules) {
rule = styleSheet.rules[ruleIndex];
}
if (rule && rule.style) {
return rule.style;
}
else {
return null;
}
}
else {
return null;
}
}
else {
return null;
}
}

function testStyleSheet () {
var style = getStyleObject(0, 0);
if (style) {
alert('style.height: ' + style.height);
}
else {
alert('style not found.');
}
}
</script>
</head>
<body onload="testStyleSheet();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>

Note that even Opera 7 doesn't support document.styleSheets. And I don't
know about Safari or Konqueror support, does anyone else care to check
and contribute?

Of course with external style sheets make sure you use <body onload
before trying to access them.

You can also check the selector of a rule with selectorText:

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getStyleObjectFromSelector (selectorText) {
if (document.styleSheets) {
for (var i = document.styleSheets.length - 1; i >= 0; i--) {
var styleSheet = document.styleSheets[i];
var rules;
if (styleSheet.cssRules) {
rules = styleSheet.cssRules;
}
else if (styleSheet.rules) {
rules = styleSheet.rules;
}
if (rules) {
for (var j = rules.length - 1; j >= 0; j--) {
if (rules[j].selectorText == selectorText) {
return rules[j].style;
}
}
}
}
return null;
}
else {
return null;
}
}

function testStyleSheet () {
var selectors = ['#aDiv', '.someClass'];
for (var i = 0; i < selectors.length; i++) {
var selector = selectors[i];
var style = getStyleObjectFromSelector(selector);
if (style) {
alert('Selector ' + selector + ': style.height: ' + style.height);
}
else {
alert('No rule found for selector ' + selector);
}
}
}
</script>
</head>
<body onload="testStyleSheet();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>


Of course if you are looking for the computed style of an object there
is no need to read through style sheet rules, getComputedStyle allows
that with Mozilla and with Opera 7 and element.currentStyle with IE5+:

<html>
<head>
<title>reading out stylesheet information</title>
<style type="text/css">
#aDiv {
color: darkgreen;
background-color: lightgreen;
height: 200px;
}
</style>
<script type="text/javascript">
function getComputedStyleForElement (element, cssPropertyName) {
if (element) {
if (window.getComputedStyle) {
return window.getComputedStyle(element,
'').getPropertyValue(cssPropertyName.replace(/([A-Z])/g,
"-$1").toLowerCase());
}
else if (element.currentStyle) {
return element.currentStyle[cssPropertyName];
}
else {
return null;
}
}
else {
return null;
}
}

function getComputedStyleForId (elementId, cssPropertyName) {
if (document.getElementById) {
return
getComputedStyleForElement(document.getElementById (elementId),
cssPropertyName);
}
else {
return null;
}
}

function testComputedStyle () {
var ids = ['aDiv', 'aP'];
for (var i = 0; i < ids.length; i++) {
var cssValue = getComputedStyleForId(ids[i], 'backgroundColor');
if (cssValue === null) {
alert('Style background-color for id ' + ids[i] + ' not found.');
}
else {
alert('Computed style for background-color for id ' + ids[i] + '
is ' + cssValue);
}
}
}
</script>
</head>
<body onload="testComputedStyle();">
<div id="aDiv">
<p>
Test.
</p>
</div>
</body>
</html>

Watch out for Netscape 7 and Opera 7 normalizing CSS values, for
instance color values are returned as rgb(r, g, b).
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #5

P: n/a
JRS: In article <zC********************@twister.nyroc.rr.com>, seen in
news:comp.lang.javascript, George Hester <he********@hotmail.com> posted
at Sat, 6 Dec 2003 18:55:27 :-
Lines: 256
Oh Martin thanks for that.

--
George Hester
__________________________________
"Martin Honnen" <ma*******@yahoo.de> wrote in message news:3f********@olaf.komte
l.net...


George Hester wrote:
> I have a css file this is a portion of it:
> ...


*Plonk*. See FTI28, and c.l.j FAQ.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 20 '05 #6

P: n/a
What's your problem? Do you just hate helpful people or do you just hate in general?

--
George Hester
__________________________________
"Dr John Stockton" <sp**@merlyn.demon.co.uk> wrote in message news:u$**************@merlyn.demon.co.uk...
JRS: In article <zC********************@twister.nyroc.rr.com>, seen in
news:comp.lang.javascript, George Hester <he********@hotmail.com> posted
at Sat, 6 Dec 2003 18:55:27 :-
Lines: 256


Oh Martin thanks for that.

--
George Hester
__________________________________
"Martin Honnen" <ma*******@yahoo.de> wrote in message news:3f********@olaf.komte
l.net...


George Hester wrote:

> I have a css file this is a portion of it:
> ...


*Plonk*. See FTI28, and c.l.j FAQ.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.

Jul 20 '05 #7

P: n/a
George Hester hu kiteb:
What's your problem? Do you just hate helpful people or do you just
hate in general?


I think his point is that requoting an extremely long post IN FULL just
to add a simple thank you is a waste of bandwidth. Most people here tend
to agree with that sentiment.
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #8

P: n/a
6KB more then yours 2KB!!!. How much bandwidth did that run the Doctor? Funny place but I hear you will try to be more considerate in the future. Can't have too many six-pence spent needlessly now can we?

--
George Hester
__________________________________
"Fabian" <la****@hotmail.com> wrote in message news:br*************@ID-174912.news.uni-berlin.de...
George Hester hu kiteb:
What's your problem? Do you just hate helpful people or do you just
hate in general?


I think his point is that requoting an extremely long post IN FULL just
to add a simple thank you is a waste of bandwidth. Most people here tend
to agree with that sentiment.


--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #9

P: n/a
George Hester wrote:
6KB more then yours 2KB!!!.
Your `!' key is borken.

Well, it sums up *and* it multiplies with every top-posting person.
[TOFU: Text Over, Fullquote Under / Top post]


*PLONK*
PointedEars
Jul 20 '05 #10

P: n/a
This works well if my stylesheet is inline or from a local file. But if
try to import a sheet where href="http://remote_server/...." then I
can't seem to access the rules for the stylesheet. I can see the
stylesheet in the StyleSheets object, but the rules collection is not
accessible. Any thoughts?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #11

P: n/a
On 03 May 2004 01:07:02 GMT, tim arthur <ti**@msn.com> wrote:
This works well if my stylesheet is inline or from a local file. But if
try to import a sheet where href="http://remote_server/...." then I
can't seem to access the rules for the stylesheet. I can see the
stylesheet in the StyleSheets object, but the rules collection is not
accessible.
To whom and to what are you responding? ALWAYS quote material that shows
the context of your post.
Any thoughts?


A URL to an example would be nice.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.