实例1.随机产生图片.html

来自「JavaScript精彩网页特效实例精粹」· HTML 代码 · 共 20 行

HTML
20
字号
<script language="JavaScript">
<!--
var a = Math.random() + ""       // 随机产生一个数
var rand1 = a.charAt(2)          // 取出小数点后面第一位数
quotes = new Array
quotes[1] = '<img src="1.gif">'            
quotes[2] = '<img src="2.gif">'
quotes[3] = '<img src="3.gif">'
quotes[4] = '<img src="4.gif">'
quotes[5] = '<img src="5.gif">'
quotes[6] = '<img src="6.gif">'
quotes[7] = '<img src="7.gif">'
quotes[8] = '<img src="8.gif">'
quotes[9] = '<img src="9.gif">'
quotes[0] = '<img src="0.gif">'
var quote = quotes[rand1]
document.write( quote )
// -->
</script>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?