Tài liệu Programming Discussion p2 - Pdf 87

Hiệu ứng làm nền web trông như Vũ Trụ

Hiệu ứng này giúp trang web của bạn trông như một vũ trụ bao la, với muôn ngàn ngôi
sao:
Paste code này ngay sau tag <body>:
PHP Code:
<BODY BGCOLOR="#000000" onLoad="fly()"> Paste code này tiếp theo sau tag <body>: ( Các bạn nhấp chuột phải xem phần "View
Source" sẽ thấy rõ )
PHP Code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
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='#FFFF
F0' CLIP='0,0,1,1'></LAYER>");

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.docume nt.body.
clientHeight;
var WinWidth = (document.layers)?window.innerWidth:window.documen t.body.c
lientWidth;
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];


Nhờ tải bản gốc
Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status