WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 help please, noname, November 28, 2003
     Re:help please, Gui Blanco, November 28, 2003
     Re:help please, Guilherme Blanco, November 28, 2003
         Re:help please, noname, November 29, 2003
             Re:help please, Erik Arvidsson, November 29, 2003
             Re:help please, Guilherme Blanco, November 29, 2003

Subject: Re:help please From: Erik Arvidsson Date: November 29, 2003
The W3C DOM gives you full access to the style sheets in the page. As far as I know only Gecko has full support for this but IE has a similar object model that allows most of the desired features. See below.

...and don't use IE CSS expressions unless you really have to. IE CSS expressions are bad.

erik



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" id="my-style">

.my-style {
background: #eee;
}

</style>
<script type="text/javascript">

function setWidthDom( s )
{
var el = document.getElementById( "my-style" );
var styleSheet = el.sheet;
var rule = styleSheet.cssRules[0];
rule.style.width = s;
}

function setWidthIe( s )
{
var el = document.getElementById( "my-style" );
var styleSheet = el.styleSheet;
var rule = styleSheet.rules[0];
rule.style.width = s;
}

function setWidth( s )
{
var el = document.getElementById( "my-style" );
var styleSheet = el.sheet &#124;&#124; el.styleSheet;
var rule = (styleSheet.cssRules &#124;&#124; styleSheet.rules)[0];
rule.style.width = s;
}


setWidth( "100px" );

</script>
</head>
<body>

<p class="my-style">Hello world</p>

<p class="my-style">Hello world</p>

</body>
</html>



Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX