请帮我一下。
示例我有以下的图像代码,并希望下面的图像在5天后被删除,如何进一步编码?
<imgsrc="http://www.quackit.com/pix/milford_sound/milford_sound_t.jpg" style="max-width:100%" alt="Milford Sound in New Zealand" />
该代码中应该添加什么代码才能使该图像在5天后删除??
删除给定URL的任何(1个或多个)IMG标签:
<img src="http://quackit.com/pix/milford_sound/milford_sound_t.jpg";
style="max-width:100%" alt="Milford Sound in New Zealand" />
从JavaScript页面中添加以下代码:
<script type='text/javascript'>
function removeThatImg() {
var ex=document.getElementsByTagName("img");
for (var i=0;i<ex.length;i++) {
if ( ex[i].src == "http://quackit.com/pix/milford_sound/milford_sound_t.jpg" )
ex[i].parentNode.removeChild(ex[i]);
}
}
var dateStart = Date.parse('March 16, 2013')/86400000;
var dateNow = new Date();
dateNow = dateNow.getTime()/86400000;
if ( dateNow - dateStart > 5) // more than 5 days
window.onload=function() {
//do it with a half second delay, because google may take time to add that image
//and right after the page is loaded it may not yet be there
setTimeout(removeThatImg,500);
}
</script>
它只是可能工作(或可能不-我认为将是这种情况,简单地说,因为图像将是不同的每次)