JSFiddle - React, Tailwind, and code Playground
by lombervid
HTML
<div id="img">
<a href="http://www.wikipwedia.com" target="_blank">
<img src="http://img3.wikia.nocookie.net/__cb20111223194956/beybladevocaloidswarriorsrp/images/5/5b/Vocaloid_rin_len_anime_display-300x300.gif" alt="">
</a>
</div>
JavaScript
var images = new Array();
var cont = 0;
images[0] = {
img: 'http://img2.wikia.nocookie.net/__cb20131207090002/ttff/images/0/01/Anime-girl-gun-300x300.png',
url: 'http://www.google.com'
}
images[1] = {
img: 'http://oi47.tinypic.com/2196ff7.jpg',
url: 'http://www.forobeta.com'
}
images[2] = {
img: 'http://wanabrar.com/blog/wp-content/uploads/2012/08/29028310-300x300.jpg',
url: 'http://www.facebook.com'
}
images[3] = {
img: 'http://huashequ.com.cn/wp-content/uploads/2013/06/6f061d950a7b0208959b39f063d9f2d3572cc855-300x300.gif',
url: 'http://www.twitter.com'
}
images[4] = {
img: 'http://i.imgur.com/ClujG.gif',
url: 'http://www.youtube.com'
}
function presImagen() {
var imgd = document.getElementById('img');
while (imgd.firstChild) {
imgd.removeChild(imgd.firstChild);
}
imgd.appendChild(createCode());
if (cont < images.length-1) cont ++;
else cont = 0;
tiempo = window.setTimeout('presImagen()',1000)
}
function createCode() {
var a = document.createElement('a');
a.href = images[cont].url;
a.target = '_blank';
var img = document.createElement('img');
img.src = images[cont].img;
a.appendChild(img);
return a;
}
window.onload = function() {
presImagen();
}