max image width: expression for IE problem

Discussion in 'HTML & Website Design' started by php_guest, Sep 26, 2009.

  1. #1
    I am using the following code with max width expression. The problem is that it starts working only when I put number higher than 1239, but the image size is 650x488px. If I put 1238 still nothing happens, it acts like the image is 1238px, but it isn't. Did I miss anything?

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <title>test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
      <style type="text/css">
        img {
          max-width: 550px; /* this sets the max-width value for all standards-compliant browsers */
          height: auto;
        } 
        img {
          width: expression( document.body.clientWidth > 1239?"22px" : "auto" ); /* sets max-width for IE */
        }
      </style>
    </head>
      <body>
        <img src="http://www.podsvojostreho.net/vsebina/sites/all/files/imagecache/bigpicture/napolitanka01/IMG_3.JPG" />
      </body>
    </html>
    HTML:

     
    php_guest, Sep 26, 2009 IP