JavaScript Tips

Buy this website for $5000 USD

Priced to sell, this is an established JavaScript website, growing in popularity as evidenced by its Alex ranking. Includes most website content. The price is NON-NEGOTIABLE. Serious buyers should contact

Using the Internet Explorer expression method in CSS

Internet Explorer for Windows has a proprietary CSS value type that is used to dynamically assign values to CSS properties. It is useful for dealing with situations where you are striving to make cross-browser web pages, and IE is not behaving in a way which is consistent with every other browser.

Below is the CSS property — background, and it is assigned a standard CSS value of red

background: red;

We can accomplish the same result as above by using the proprietary IE expression method to set the value:

background: expression('red');

The value passed to the expression method is really a JavaScript expression. So, for example, this would result in the background property being set to blue:

background: expression(true ? 'blue' : 'red');

Since other browsers ignore the expression method, this allows you to uniquely set CSS values for IE. For example, this sets the background color of the body element to blue in IE, and red in all other browsers.

body
{
   background: red;
   background: expression('blue');
}