Tuesday, March 19, 2019

Replace CSS Expression with JavaScript


CSS Expression is only supported in IE7 and older versions. To make the web site using CSS Expression display properly in newer browsers, CSS Expression can be replaced with JavaScripts.

For example, the following code:

<table border='1'>
  <tr>
    <td style='width:10'>1</td>
    <td style='width:expression(body.clientWidth -10);'>2</td>
  </tr>
</table>

can be replaced into:

<table border='1'>
  <tr>
    <td style='width:10'>1</td>
    <td id='td2'>2</td>
  </tr>
</table>

<script type='text/javascript'>
  var elm = document.getElementById('td2');
  elm.style.width = document.body.clientWidth - 10;
</script>

No comments:

 
Get This <