当前位置:首页>>空间代码>>空间代码>>正文

QQ空间:随即图片的探讨

文章出处:设计前沿收集 作者:未知 发布时间:2006-05-14 收藏到QQ书签

演示地址:

www.qfans.net/qzone/qzonetest.htm

一个随即图片的站,每次进去jay的图片都不一样


<td valign="top"><script language="JavaScript">
<!--
imagenum1=Math.round(Math.random()*4)+1
if (imagenum1==1){var image1="<IMG SRC=04imgs/05win1_p01.jpg BORDER=0>"}
else if (imagenum1==2){var image1="<IMG SRC=04imgs/05win1_p02.jpg BORDER=0>"}
else if (imagenum1==3){var image1="<IMG SRC=04imgs/05win1_p03.jpg BORDER=0>"}
else if (imagenum1==4){var image1="<IMG SRC=04imgs/05win1_p04.jpg BORDER=0>"}
else if (imagenum1==5){var image1="<IMG SRC=04imgs/05win1_p05.jpg BORDER=0>"}
document.write (image1)
// -->
</script></td>



用的是这个代码



图片为

















讲解:
script language="JavaScript"
说明代码是js属性的代码


imagenum1=Math.round(Math.random()*4)+1

说明是5取1 随即提取

如果要增加随即图片的数量的话,改4 的数值,
相映的

if (imagenum1==1){var image1="<IMG SRC=04imgs/05win1_p01.jpg BORDER=0>"}
else if (imagenum1==2){var image1="<IMG SRC=04imgs/05win1_p02.jpg BORDER=0>"}
else if (imagenum1==3){var image1="<IMG SRC=04imgs/05win1_p03.jpg BORDER=0>"}
else if (imagenum1==4){var image1="<IMG SRC=04imgs/05win1_p04.jpg BORDER=0>"}
else if (imagenum1==5){var image1="<IMG SRC=04imgs/05win1_p05.jpg BORDER=0>"}

也要继续多上去
他这里的图片是相对路径,用dw做站的时候,所有人都是用相对路径的
只要在前面加上站的地址 就是绝对路径了



http://www.metersbonwe.com.cn/04imgs/05win1_p05.jpg


改成10的话
imagenum1=Math.round(Math.random()*10)+1
就是说有11种随即
相映的下面也要加11张图片

QQ粉丝网 www.qfans.net   www.qqvan.com QQ先锋

在说说鬼手提供给我的随即皮肤的代码

代码:


var pic_url = new Array
(
"http://12koku.bbs.topzj.com/attachments/m18/18/77/18779/forumid_5449/200410210907_816989_L6EAPfIbrCGH.jpg",
"http://free.getbbs.com/Images/PostUpload/PostUpload-104599-505845-2005-10-3-632639551044375000.gif",
"http://freefilehosting.net/file/?id=qNjyl6zb",
"http://image2.sina.com.cn/ast/ot/2005-09-08/U1490P54T3D21631F59DT20050908201105.jpg",
"http://img013.photo.wangyou.com/2005/7/2/111888/200511220221680.jpg",
"http://photoimg19.qq.com/cgi-bin/load_pic2?verify=uWf41ijKGiegXeN7ly%2F3dQ%3D%3D",
"http://www.zcyl.cn/bbs/UploadFile/2005-8/2005827035975873.jpg",
"http://photoimg60.qq.com/cgi-bin/load_pic2?verify=kZfdiNhOOUACVMMWj%2Fqhzg%3D%3D",
"http://photoimg64.qq.com/cgi-bin/load_pic2?verify=X0YoSF%2BADlr5gUjFboS6Ow%3D%3D",
"http://photoimg65.qq.com/cgi-bin/load_pic2?verify=KuB.hlVaPExUBhjZ0dHUIw%3D%3D",
"http://photoimg65.qq.com/cgi-bin/load_pic2?verify=q9UWTwdveDkpzpFuldUC1Q%3D%3D",
"http://www.heartyue.com/bbs/upload/43/20041024204735.jpg",
"http://www.wzw131.com/6city/bbs/uploadfile/2004-11/20041123132915127.jpg"
);
function droson_background()
{
var iRand;
iRand = Math.random()
iRand = Math.round(iRand*14+1);
document.getElementById('all').style.background='url('+pic_url[iRand]+')';
document.getElementById('Mlogo').style.background='';
}
droson_background();




这个是可以直接用进q-zone的随即图片代码


这个是q-zone皮肤的代码
ocument.getElementById('all').style.background='url('+pic_url[iRand]+')';
document.getElementById('Mlogo').style.background='';



还原代码:


var pic_url = new Array
(
"图片地址1",
"图片地址2",
"图片地址3",
"图片地址4",
"图片地址5"
);
function droson_background()
{
var iRand;
iRand = Math.random()
iRand = Math.round(iRand*6+1);
document.getElementById('all').style.background='url('+pic_url[iRand]+')';
document.getElementById('Mlogo').style.background='';
}
droson_background();




只要图片地址带进去,保存js格式
上传自己的可以上传的空间[这里说的空间不是q-zone]


<img src="javascript:var s=document.createElement('script');s.src='上传js的地址';document.body.appendChild(s);" style=display:none></img>


就可以有自己的随即皮肤了~


QQ粉丝网 www.qfans.net   www.qqvan.com QQ先锋


第2种是现成的~~ 我说了原理了,只要改改“美特斯邦威” 的也可以做随即皮肤
加q-zone皮肤的代码


document.getElementById('all').style.background='url('随即图片参数')';
document.getElementById('Mlogo').style.background='';
有能力的自己开发

QQ粉丝网 www.qfans.net   www.qqvan.com QQ先锋

大家可以参考参考,共同进步



Google