Get img src from dynamically loaded img using jQuery

I'm looking for getting an image from an image with src dynamically loaded. I mainly use the google chat icon on the site to chat. And also, where on the page, I have a picture that says Live Chat: Online or Live Chat: Offline. And I want this to change depending on whether it is available to me in the chat or not. It makes sense?

Anyway, the easiest way I'm going to do is check the img url. If img is offline.gif then obviously I'm 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 is 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 makes sense now.

Thanks heaps

+2


a source to share


1 answer


It is possible that the image itself is generated dynamically, in which case there will be no other source. The only reason you'll see a different source when viewing it is because of the generated image content headers.

If the src itself changes dynamically, your best bet is to simply get the src attribute from that element.



If by accident what you're actually looking for is a way to programmatically find a way to know if you are offline or online, you can try to get the alt attribute from the image. Most websites have an alt description for the image element, and it should probably be read online if an online image is displayed, or offline if an offline image is displayed.

0


a source







All Articles