Thursday, August 12, 2010

Some coincidence

This one's real silly, but somehow I just couldnt resist writing about it.

Was on my way to work today when I enter the tube and the person sitting in the corner seat right in front of me was wearing the same shoes. Its been a while since I bought these shoes but haven't really wanted to wear them. And now that have started wearing them, didnt really expect them to have lasted that long to be seeing them on someone else's feet. But a strange coincidence, especially when you know that these shoes weren't too many in stock when I went to buy them and they end up on another pair of feet sitting right next to the one I was sitting on in the tube. 

Oh well, coincidence or destiny call it whatever you will.

Monday, August 02, 2010

IMG onError Attribute

There always is a lot of talk going on about jQuery and similar such frameworks. There have been loads of exciting things that can be done with them as well. But I still sometimes remain unsure about some of the things that are done with jQuery which can instead be done by simple Javascript? Maybe this isn't supported by all browsers or something but am not really sure.

There's a jQuery plugin to display an alternative image when the current image we are looking up results in an error.

Am not so sure if what am going to suggest is the right way of doing it, but probably one of the ways of doing it I assume.

For the IMG Tag in HTML, you do have an onError attribute where you can specify that if the image didnt load, then load another existing image. 

So for example, if your looking at:

<img class="thumbnail" width="75" height="50" src="sourceImage" alt="Alt Text to display"  onerror="this.src='defaultExistingImage'" />
 
And in this case sourceImage is referring to an image that doesnt exist, the browser invokes the onError event using which you could specify the source for the image to a default one.

Sounds simple, and its been tested on a wide variety of browsers when I looked up the net. So the newer ones including the standard IE6/7,Firefox and Chrome do support it.

Now am not sure why use jQuery when you can do something as simple as this?

Labels: , , , ,