I have a CSS file, which contain the style information of my web. Some height & width is based on the screen size, so I can calculate the size using the Javascript, can I embedded the javascript in the CSS file to do so?
I have a CSS file, which contain the style information of my web. Some height & width is based on the screen size, so I can calculate the size using the Javascript, can I embedded the javascript in the CSS file to do so?
Share Improve this question edited Oct 25, 2009 at 11:35 Gabriel Hurley 40.1k14 gold badges63 silver badges89 bronze badges asked Oct 25, 2009 at 10:37 DNB5brimsDNB5brims 30.6k50 gold badges134 silver badges204 bronze badges2 Answers
Reset to default 7In IE, and only IE, you can use CSS expressions:
width: expression(blah + "px");
Then width
bees whatever's inside the brackets.
This only works in IE, though - so don't use it. Use a JS function to assign the elements the style with element.style.width
or similar.
For example:
<script type="text/javascript">
document.getElementById('header').style.width = (100 * 2) + 'px';
</script>
I don't think so, but you can do the opposite, i.e. make the javascript create an inline css on the fly.