101010 2006-11-9 07:15
论坛背景特效(星空背景)全局显示
[quote][b][size=3][color=red]论坛背景特效(星空背景)全局显示
[code]<BODY bgColor=#000000 onload=fly()><SCRIPT language=JavaScript>
<!--
SmallStars = 30;
LargeStars = 10;
SmallYpos = new Array();
SmallXpos = new Array();
LargeYpos = new Array();
LargeXpos = new Array();
Smallspeed= new Array();
Largespeed= new Array();
ns=(document.layers)?1:0;
if (ns){
for (i = 0; i < SmallStars; i++)
{document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0' CLIP='0,0,1,1'></LAYER>")}
for (i = 0; i < LargeStars; i++)
{document.write("<LAYER NAME='ln"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFFF' CLIP='0,0,2,2'></LAYER>")}
}
else{
document.write('<div style="position:absolute;top:0px;left:0px">');
document.write('<div style="position:relative">');
for (i = 0; i < SmallStars; i++)
{document.write('<div id="si" style="position:absolute;top:0;left:0;width:1px;height:1px;background:#fffff0;font-size:1px"></div>')}
document.write('</div>');
document.write('</div>');
document.write('<div style="position:absolute;top:0px;left:0px">');
document.write('<div style="position:relative">');
for (i = 0; i < LargeStars; i++)
{document.write('<div id="li" style="position:absolute;top:0;left:0;width:2px;height:2px;background:#ffffff;font-size:2px"></div>')}
document.write('</div>');
document.write('</div>');
}
WinHeight=(document.layers)?window.innerHeight:window.document.body.clientHeight;
WinWidth=(document.layers)?window.innerWidth:window.document.body.clientWidth;
//Inital placement!
for (i=0; i < SmallStars; i++)
{
SmallYpos[i] = Math.round(Math.random()*WinHeight);
SmallXpos[i] = Math.round(Math.random()*WinWidth);
Smallspeed[i]= Math.random()*5+1;
}
for (i=0; i < LargeStars; i++)
{
LargeYpos[i] = Math.round(Math.random()*WinHeight);
LargeXpos[i] = Math.round(Math.random()*WinWidth);
Largespeed[i]= Math.random()*10+5;
}
function fly(){
var WinHeight=(document.layers)?window.innerHeight:window.document.body.clientHeight;
var WinWidth=(document.layers)?window.innerWidth:window.document.body.clientWidth;
var hscrll=(document.layers)?window.pageYOffset:document.body.scrollTop;
var wscrll=(document.layers)?window.pageXOffset:document.body.scrollLeft;
for (i=0; i < LargeStars; i++)
{
LargeXpos[i]-=Largespeed[i];
if (LargeXpos[i] < -10)
{
LargeXpos[i]=WinWidth;
LargeYpos[i]=Math.round(Math.random()*WinHeight);
Largespeed[i]=Math.random()*10+5;
}
if (ns){
document.layers['ln'+i].left=LargeXpos[i];
document.layers['ln'+i].top=LargeYpos[i]+hscrll;
}
else{
li[i].style.pixelLeft=LargeXpos[i];
li[i].style.pixelTop=LargeYpos[i]+hscrll;
}
}
for (i=0; i < SmallStars; i++)
{
SmallXpos[i]-=Smallspeed[i];
if (SmallXpos[i] < -10)
{
SmallXpos[i]=WinWidth;
SmallYpos[i]=Math.round(Math.random()*WinHeight);
Smallspeed[i]=Math.random()*5+1;
}
if (ns){
document.layers['sn'+i].left=SmallXpos[i];
document.layers['sn'+i].top=SmallYpos[i]+hscrll;
}
else{
si[i].style.pixelLeft=SmallXpos[i];
si[i].style.pixelTop=SmallYpos[i]+hscrll;
}
}
setTimeout('fly()',10);
}
//fly();
//-->
</SCRIPT></Body>
[/code]
把上面代码放到头部信息里就OK了,本人亲测,决不会溢出,请放心使用。
演示论坛:[url=http://wvvw.tv.topzj.com/]http://wvvw.tv.topzj.com/[/url][/size][/color][/b][/quote]
[[i] 本帖最后由 101010 于 2006-12-4 09:17 编辑 [/i]]
raogn 2006-11-9 08:23
不是星空背景吧。倒像是飞雪背景,没什么意思,怎么不是从上往下,的。从右往左的不好
03zy 2006-11-9 22:12
晕
这么垃圾的代码你也用啊,没什么好看的,建议大家也别使用,因为我用过,效果不好的,而且一般影响风格,使你的风格更不好看的.:@
hongmo99 2006-11-11 03:24
飘过。。。。。。:(
zhendeainio 2006-11-13 03:48
*** 作者被禁止或删除 内容自动屏蔽 ***
An_Apple 2006-11-13 04:54
不错,呵呵。
偶还是不用了把,影响速度,呵呵。:lol
101010 2006-12-4 09:10
演示效果我已经去了,不可能长时间放着啊。呵呵~~我测试过。可以用的
水映云轩 2006-12-4 10:15
[quote]原帖由 [i]风飞雪[/i] 于 2006-12-4 10:13 发表
头部信息在哪呀!!!!! [/quote]
Discuz! 选项——搜索引擎优化——其他头部信息:
whl790826 2006-12-11 21:20
有没有演示啊
hongfei610 2006-12-21 21:15
卡死我了````````
蓝色雪貂 2007-3-3 17:07
不好看,一点都不好看.!!!!!!!上当拉!:'( :L
caihao2000 2007-3-15 14:03
不好用
骗人
tieshou 2007-3-25 17:07
:lol [size=4][color=Red][b]有好看的没有?[/b][/color][/size]
孤行岁月 2007-6-4 11:18
回复 #1 101010 的帖子
不错,先收藏了再说
babyling 2007-7-14 18:16
还可以
不过白色风格的都不能显示啊
有其他的吗》?
benson7758 2007-9-14 13:55
学习中......谢谢楼主
diy1 2008-4-25 23:50
LZ想问个问题:这个代码我看过了,什么是全局。这个代码用不用都是一样的啊,因为你的背景本来就是一个颜色,后台随便加一个页面背景图片就可以了啊,
cz2008dd4 2008-4-28 10:11
我的设置后也不显示
henshuiyouyu 2008-6-30 06:40
代码太长了:L
teng7758258 2008-10-2 19:58
啊....能不能用啊