SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Threaded View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    resize images on load

    trying to resize images based on their hxw so I'm not stretching out tall pictures with css. What am i doing wrong here?

    Code JavaScript:
    resizePics = function()
    {
       rsRoot = document.getElementById("resize");
       for (i=0; i<rsRoot.childNodes.length; i++)
       {
         node = rsRoot.childNodes[i];
         if (node.className=="preview")
         {
           node.onload=function()
           {
            this.height = this.height * .5
            this.width = this.width * .5
           }
         }
       }
    }
     
    window.onload=function(){
       resizePics();
    }

    Code HTML4Strict:
    <tr>
     <td align="center" id='resize'>
      <ul class='hoverbox'>
        <li ><a href='showpicture.php?id=69&n=1&t=main'><img src="pics/69/main/1-thumb.jpg" /><img class='preview' src='pics/69/main/1.jpg'/></a> </li> 
        <li ><a href='showpicture.php?id=69&n=3&t=main'><img src="pics/69/main/3-thumb.jpg" /><img class='preview' src='pics/69/main/3.jpg'/></a> </li> 
      </ul>
     </td>
    </tr>
    Last edited by joejoeknows; Jul 5, 2007 at 13:45.


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
  •