Hans Rasmussen

info@hansrasmussen.com, +46 (0)723 207008

Empty scr attribute on image element causing reload

Be aware when using empty scr attributes in your webpages, as they cause loads to either the same page as the element is specified from or a load of the default page in the same directory where the page is located (depending on browser implementation). If your page / default page has some session handling or logics evaluating on query strings an image load will then accidentally be mistaken by your page as a new request. Depending on how you are implementing server side logics on the new request, it might cause you problems.

If you need to update your elements dynamically (with javascript/jQuery), then rather add the attribute when it is needed and never inject the attribute empty.

http://www.nczonline.net/blog/2009/11/30/empty-image-src-can-destroy-your-site/

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

*