image resizing script works in firefox but not chrome

image resizing script works in firefox but not chrome

I have this image resizing script:

  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
  5.     <script>
  6.       $(document).ready(function() {
  7.         $(".bbimg").each(function() {
  8.           var width = $(this).width();
  9.           $(this).width(0);
  10.           var maxwidth = $(this).closest("div").width();
  11.           if (width > maxwidth) {
  12.             $(this).width(maxwidth-2).css("border", "1px solid #ef007c");
  13.             $(this).click(function() { window.open (this.src); });
  14.           } else {
  15.             $(this).width(width);
  16.           }
  17.         })
  18.       })
  19.     </script>
  20.   </head>
  21.   <body>
  22.     <div style="width:570px">
  23.       <img src="http://homensmodernos.files.wordpress.com/2009/09/trees.jpg" class="bbimg" />
  24.     </div>
  25.   </body>
  26. </html>
All it should do is get the width of an image with class bbimg, set the width to 0, find the width of the containing div, compare this width to the original width of the image. If the original width is bigger, then it will scale the image down to the maxwidth of the div.

This works in firefox flawlessly, but in chrome, the page is just blank. I have the exact script here:  http://zeroboy.net/test.php

Any reason why this would happen?