Closed Thread Icon

Topic awaiting preservation: DOM - List inline style names (IE) (other browsers?) (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8883" title="Pages that link to Topic awaiting preservation: DOM - List inline style names (IE) (other browsers?) (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: DOM - List inline style names (IE) (other browsers?) <span class="small">(Page 1 of 1)</span>\

 
Dick Ulrich
Bipolar (III) Inmate

From: Dublin, TX, USA
Insane since: Sep 2003

posted posted 10-02-2003 04:25

Hi,

Sure wish I could have other browsers here, but can't for now.

Can anyone try something out for me in other browsers? It works in IE.
Thanks, Dick

<html>
<head>

<title>TestPage for List Inline Style Names</title>

<style>
.nameofstyle1
{
width:80px;
height:100px;
}
.nameofstyle2
{
height:200px;
}
</style>
<style>
.nameofstyle3,.nameofstyle4
{
font-family:verdana;
}
</style>

<script>
//for ie(6)
function ListInlineStyleNames()
{
var result = '<table border=1 style="font-size:12px;color:blue;">';
result += '<tr><th>Style Name</th><th>Style Content</th></tr>';
for (var si=0; si < document.styleSheets.length; si++)
for (var ri=0; ri < document.styleSheets[si].rules.length; ri++)
{
var rules = document.styleSheets[si].rules(ri);
result += '<tr><td>'+ rules.selectorText +'</td><td>'+ rules.style.cssText +'</td></tr>';
}
result += '</table>';
return result;
}
</script>
</head>
<body BGCOLOR="#cccccc"></body>
</html>

<script>
document.body.innerHTML = '<h1>Does This Work In Other Browsers?</h1>'+ListInlineStyleNames();
</script>

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 10-02-2003 08:26

In other borwsers you should use:

document.styleSheets[index].cssRules[index]

instead of:

document.styleSheets[index].rules[index]


Dick Ulrich
Bipolar (III) Inmate

From: Dublin, TX, USA
Insane since: Sep 2003

posted posted 10-02-2003 11:48

Thanks Mr. MadX ...

Dick Ulrich
Bipolar (III) Inmate

From: Dublin, TX, USA
Insane since: Sep 2003

posted posted 10-02-2003 12:09

Mr. MaX (anyone else too)

How would you combine these two functions to make one, if there were variables available such as 'isIE'

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 10-02-2003 12:28

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Dick Ulrich
Bipolar (III) Inmate

From: Dublin, TX, USA
Insane since: Sep 2003

posted posted 10-02-2003 12:36

I got up at 3:45AM (that is probably the problem :-)
but, I tried your suggestion and I must have not done what you had in mind.
Could you take a look and see what I screwed up??

function ListStyleNames()
{
var res = '<table border=1 style="font-size:16px;color:blue;">';
res += '<tr><th>Style Name</th><th>Style Content</th></tr>';
for (var si=0; si < document.styleSheets.length; si++)
{
var cssRulesLength = (document.styleSheets[si].cssRules(ri))?document.styleSheets[si].cssRules.length:document.styleSheets[si].rules.length;
for (var ri=0; ri < cssRulesLength.length; ri++)
{
var cssRules = (document.styleSheets[si].cssRules(ri))?document.styleSheets[si].cssRules(ri):document.styleSheets[si].rules(ri);
res += '<tr><td>' + cssRules.selectorText +
'</td><td>'+ cssRules.style.cssText +
'</td></tr>';
}
}
res += '</table>';
return res;
}

Thanks,
Dick (<-- still trying to learn)

Dick Ulrich
Bipolar (III) Inmate

From: Dublin, TX, USA
Insane since: Sep 2003

posted posted 10-02-2003 12:41

Finally, Does this one work in non-IE>

function ListStyleNames()
{
var res = '<table border=1 style="font-size:16px;color:blue;">';
res += '<tr><th>Style Name</th><th>Style Content</th></tr>';
for (var si=0; si < document.styleSheets.length; si++)
{
alert(document.styleSheets[si].cssRules);
var cssRulesLength = (document.styleSheets[si].cssRules)?document.styleSheets[si].cssRules.length:document.styleSheets[si].rules.length;
for (var ri=0; ri < cssRulesLength; ri++)
{
var cssRules = (document.styleSheets[si].cssRules)?document.styleSheets[si].cssRules(ri):document.styleSheets[si].rules(ri);
res += '<tr><td>' + cssRules.selectorText +
'</td><td>'+ cssRules.style.cssText +
'</td></tr>';
}
}
res += '</table>';
return res;
}

Thanks,
Dick

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 10-02-2003 12:49

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

« BackwardsOnwards »

Show Forum Drop Down Menu