怎么用js制作一个骰子点数图片,点击是可以自动旋转并随机获得一个点数(图片我

js实现网页html随机切换背景图片 | 一聚教程网
js实现网页html随机切换背景图片
&&& 在script中将这些图像编为一个数组,便于调用。数组的长度当然就是图像的数量。
var bodyBgs = [];&&& //创建一个数组变量来存储背景图片的路径
bodyBgs[0] = "images/01.jpg";
bodyBgs[1] = "images/02.jpg";
bodyBgs[2] = "images/03.jpg";
bodyBgs[3] = "images/04.jpg";
bodyBgs[4] = "images/05.jpg";
&&& 因为上面用到了5个图像,所以在这里需要产生一个0到4的随机数。如果数组长度不一样,修改下面代码中的乘数就可以。
var randomBgIndex = Math.round( Math.random() * 4 );
&&& 核心的程序就是这些。尽管很简单,却是一种小小的思路,若以此为基础,通过加工可以做出一些扩展功能。比如:主题切换以及其它的随机呈现等等。下面是完整的JS代码。一个有趣的JS:随机效果文本-定时的从一段文本中随机选择一个字
&!doctype html public &-//w3c//dtd html 4.0 transitional//en&&&
&script language=&javascript&&&
function open () {}&
&/script&&
&title&ripple text examples by mark boyle email &/title&&
&body bgcolor=green text=&white& bgcolor=&green& link=&yellow& vlink=&yellow&&&
alink=&red&&&
&font color=&yellow&&&
&script language=&javascript&&&
var speed = 20;&
if(navigator.appname == &netscape&)&
document.write(&layer id=&wds&&&/layer&&br&);&
if (navigator.appversion.indexof(&msie&) != -1)&
document.write(&span id=&wds&&&/span&&br&);&
function livetext()&
fulltext=&this is an example of random effect text&&
var whichchar=math.round((math.random()*fulltext.length))&
switch(whichchar){&
fulltext = &font color=&red&& + fulltext.substring(0,1) + &/font& + fulltext.substring&
(1,fulltext.length);&
case fulltext.length:&
fulltext = fulltext.substring(0,fulltext.length-1) + &font color=&red&& + fulltext.substring&
(fulltext.length-1,fulltext.length) + &/font&;&
fulltext =&&
fulltext.substring(0,whichchar) + &font color=&violet&& +&
fulltext.substring(whichchar,whichchar+1) + &/font& +&
fulltext.substring(whichchar+1,fulltext.length);&
if(navigator.appname == &netscape&) {&
size = &&font point-size=25pt&&;&&
document.wds.document.write(size+&center& + fulltext + &/center&&/font&);&
document.wds.document.close();&
if (navigator.appversion.indexof(&msie&) != -1){&
wds.innerhtml = &center& + fulltext + &/center&&p&;&
wds.style.fontsize=25px&
settimeout(&livetext()&,speed);&
livetext()&
&/script&&
文章整理:西部数码--专业提供、服务
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467142',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'

我要回帖

更多关于 骰子点数图片 的文章

 

随机推荐