我基本上试图设置它,以便当我点击我的网站上的按钮时,页面刷新从数组随机一块文本和随机图像来自一个数组。我已经把文本部分放下了,但是需要知道如何去做图片部分。这是我现在使用的文本生成脚本:脚本从数组中随机生成图片和文本
<script language="JavaScript">
var r_text = new Array();
r_text[0] = "You'll want to track-change your life";
r_text[1] = "A misplaced comma can get you fired";
r_text[2] = "Work-life balance? Ha!";
r_text[3] = "Even the bankers laugh at you";
r_text[4] = "There's a gym so you can't leave the building";
r_text[5] = "Student debt can't be discharged";
r_text[6] = "Sallie Mae becomes one of your biggest contacts";
r_text[7] = "Good luck with partner track";
r_text[8] = "There are no lifestyle firms";
r_text[9] = "Your soul will die";
r_text[10] = "Socratic Method? More like Suck-ratic Method";
r_text[11] = "So much paper. You'll be destroying rainforests";
var i = Math.floor(12*Math.random())
document.write(r_text[i]);
</script>
上我能做些什么来获得图像,这里的任何想法?
我认为这是有效的。 gif需要与主html文件位于同一个文件夹中,对吗? – 2012-04-05 14:52:37
你的'src ='''指定在哪里查找imgs,即:'src ='images/1.gif'' - 表示文件夹'images'与显示它们的页面处于同一级别 – Elen 2012-04-05 14:53:59