SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Enthusiast nickweavers's Avatar
    Join Date
    Feb 2004
    Hampshire, UK
    0 Post(s)
    0 Thread(s)

    Stale image properties after image reload

    I am just finishing some javascript & PHP to allow members of a community website to upload a new picture of themselves. The upload page shows the members current image if there is one or a silhouette image if not. The page uses a form with enctype="multipart/form-data" method="post" and a button of type="file" to allow the member to browse to and select his/her new image. The upload is performed without a page refresh using the excellent Connection Manager from the Yahoo! User Interface Library.

    When the user clicks the upload button the image is uploaded by the connection manager and the uploadResponse callback invokes my response function. If the uploaded image has simply been replaced, this response function causes the image to be reloaded by reassigning it's src property to the same url as before but with a '?' + now.getTime() appended to ensure the browsers cached version is replaced.

    So far so good, and I am gratified by seeing the image updated in place. The next step is where I am seeing some behavior I didn't expect. The remaining functions allow the uploaded image to be cropped and involve using the images offsetLeft, offsetTop, offsetHeight and offsetWidth to define a boundary inside which a 500px x 500px translucent DHTML div can be dragged around as a cropping window.

    What I think I am seeing is that although the assignment to the src property causes the image to be reloaded, it doesn't seem to result in the offsetLeft, offsetTop, offsetHeight and offsetWidth properties to be updated to match. Can anyone tell me if this is what would be expected? If so, is there any way in which I can also force them to be refreshed?

    I have only tried this under Firefox so far as my code is peppered with console.log messages which I don't want to remove yet and these cause IE to barf (wish I done something like dbug - a console.log (firebug) wrapper).
    Last edited by nickweavers; Dec 23, 2006 at 16:08.


Posting Permissions

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