SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Evangelist jimday1982's Avatar
    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    562
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Image resizing not working in IE7

    Hello all-

    I just noticed an issue on my site where my image resizing code does not appear to be working correctly in IE7. The code that I'm using is:

    Code:
    <script type="text/javascript">
    function setImageDimensions(gotImage)
    { 
    if(gotImage.width > 500) {
        gotImage.width = 500;
      }
    }
    function changeImageDimensions(gotImage, type)
    {
      if(gotImage.width > 500 && type == 'out') {
        gotImage.width = 500;
        return;
      }
      if(type == 'over') {
        gotImage.removeAttribute('width');
      }
    }
    </script>
    And I'm calling each image using:

    Code:
    <img onload="setImageDimensions(this)" src="http://i116.photobucket.com/albums/o13/scrapncathy/Katie-BeauXmas06.jpg" border="0" />
    It appears to be working just fine in other browsers and I'm not exactly sure what I'm doing wrong. My desired result is to automatically change the width of the images to 500px if they are initially wider than that.

    Thank you so much for your help.

    EDIT - just realized that it's not working in IE 6 either...
    Jimmy Day
    Senior Systems Analyst
    Piedmont Healthcare Corporation

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi neighbor

    The following works for me in IE 6 and 7. Is this a page you can give us a link to?

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Template</title>
    <style type='text/css'>
    </style>
    <script type='text/javascript'>
    function setImageDimensions(gotImage)
    { 
    if(gotImage.width > 500) {
        gotImage.width = 500;
        alert('set');//////////
      }
      else alert('not set');///////
    }
    </script>
    </head>
    <body>
    <img onload="setImageDimensions(this)" src="" border="0">
    </body>
    </html>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •