views:

234

answers:

1

Hey Guys (and Ladies)

I am looking at getting the image name from an image with a src loaded dynamically. Basically what I am doing is using the Google chat badge on a site to live chatting. And else where on the page, I have an image saying Live Chat:Online or Live Chat:Offline. And I want this to change depending on whether I am available to chat or not. Does this make sense?

Anyway, the easiest way I figure to do this would be check the img url. If the img is offline.gif then obviously I am offline.

An example of a dynamically loaded img would be something like

<img src="http://www.google.com/talk/service/badge/Show?encrypted_acount_id_here" />

Once this image has loaded, it loads one of the following images "http://www.google.com/talk/service/resources/offlinef.gif" "http://www.google.com/talk/service/resources/idlef.gif" "http://www.google.com/talk/service/resources/onlinef.gif"

Hopefully this make sense now.

Thanks heaps

A: 

It's possible that the image itself is generated dynamically in which case there wont be another source. The only reason you would see another source when you view it's properties is because of the content headers of the generated image.

If the src itself however is changed dynamically your best bet would to just get the src attribute from the element.

If by chance what you actually are looking for is a way to programatically find a way to know if you are offline or online, you could try to get the alt attribute from the image. Most websites have an alt description for the image element and it should hopefully read online if the online image is showing or offline if the offline image is showing.

Jonas B

related questions