1

I got a rss feed of a cartoon. how can I check if the URL of the image exists. if not, I have 4 local images and I want to display them in sequential order.

this is what I got:

google.load("feeds", "1");

function initialize() {
  var feed = new google.feeds.Feed("http://rss.xiffy.nl/foksuk.php");
  feed.setNumEntries(1);
  feed.setResultFormat(google.feeds.Feed.MIXED_FORMAT)
  feed.load(function(result) {
    if (!result.error) {
      var container = document.getElementById("feed");
      for (var i = 0; i < result.feed.entries.length; i++) {
        var entry = result.feed.entries[i];
        var ul = document.createElement("ul");
        var li = document.createElement('li');
        var entryImageUrl = entry.xmlNode.getElementsByTagName("description")[0].getAttribute("url");
        li.innerHTML = '<div id="tekst">' + entry.content + '</div>';
        ul.appendChild(li);
        container.appendChild(ul);
      }
    }
  });
}
   setTimeout((initialize),300);

Jai Chauhan
  • 4,035
  • 3
  • 36
  • 62
user2811083
  • 83
  • 2
  • 9
  • Check these: http://stackoverflow.com/questions/14651348/checking-if-image-does-exists-using-javascript http://stackoverflow.com/questions/3381663/check-if-image-exists-with-given-url-using-jquery – Matti Lehtinen Sep 25 '13 at 09:08

1 Answers1

0

Try this. Check for 404 Error.

var request = new XMLHttpRequest();  
request.open('GET', URL, true);  
request.send();  

if (request.status === "404") {  
alert("Image does not exist");
}  
Jabran Saeed
  • 5,760
  • 3
  • 21
  • 37