html - Esablishing if file exists on another domain using javascript -


i wish test javascript within html page if following files exist or not:

http://www.focloir.ie/media/ei/sounds/ag_c.mp3  // exists http://www.focloir.ie/media/ei/sounds/og_c.mp3  // doesn't exist 

my html page not on same domain files above.

is possible?

i wish solve using single html file (no db or php etc.) since project simple prototype.

this looks promising, although super slow , ugly :)

var _word = "ag"; var _audio = audio();  function update_src(audio, word) {     if (audio.canplaytype('audio/mpeg;')) {         audio.src = "http://www.focloir.ie/media/ei/sounds/" + word + "_c.mp3";     } else {         audio.src = "http://www.focloir.ie/media/ei/sounds_ogg/" + word + "_c.ogg";     } }  update_src(_audio, _word); _audio.load(); _audio.addeventlistener("durationchange", function () {     alert("exits"); }); 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -