我有这个每日图像旋转脚本,效果很好。我需要图像可点击。任何帮助表示赞赏。
<!-- Begin
today = new Date();
day = today.getDay();
arday = new Array
("http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_3575.jpg",
"http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_mp_mpl.jpg",
"http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_mph.jpg",
"http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_mmp.jpg",
"http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_mep.jpg",
"http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_mst.jpg",
"http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_s.jpg",
"http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_maxp.jpg",
"http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_mpt.jpg",
"http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_mta.jpg",
"http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_me.jpg",
"http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_sm.jpg");
document.write("<img src='" + arday[day] + "'>");
// End -->
</SCRIPT>
答案 0 :(得分:0)
为什么不写一个<a>
元素?
document.write('<a href="LINK_HERE" title="TITLE_HERE"><img src="' + arday[day] + '"><\/a>');
答案 1 :(得分:0)
可点击到哪里?除了img src
之外,您还必须为每个“行”添加网址。
例如,而不是每行只是"http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_3575.jpg",
而是:
{ img: "http://www.magnatexpumps.com/imagesnew/featured/featuredProduct_3575.jpg",
url: "LINK GOES HERE" },
然后最后一行可以做到:
document.write('<a href="' + arday[day].url + '"><img src="' + arday[day].img + '" /></a>');
答案 2 :(得分:0)
以下示例在您的图片周围创建一个链接,只需更改href属性的值:
document.write("<a href='#'><img src='" + arday[day] + "' border='0'></a>");
答案 3 :(得分:0)
一般提示:
var today = ...
,而不只是today = ...
)new Array
以支持更简洁(并且最近兼容)“[”和“]”语法。