| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6158 人关注过本帖
标题:无聊找了点网页特效代码!!
只看楼主 加入收藏
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

一个很COOL的东东!!(用鼠标左右上下键来控制的QQ)


<script>
var smapdata = new Array(
"11111111111111111111",
"10000000000000000001",
"10010000000000000001",
"10010022000000000001",
"11010000000000000301",
"10010111110000003001",
"10000001300000000301",
"11111001000010000001",
"10000001000000000001",
"10000001000000111001",
"10000000000000000001",
"10000000011110000001",
"10021200000000000001",
"10000000000000000001",
"11111111111111111111"
)

var mapData =new Array(15);
var spriteX=0;
spriteY=0;
var winbox=0;

function readMap(){ //重建地图信息便于程序使用。
for(var i=0;i<15;i++){
mapData[i]=new Array(20);
for(var j=0;j<20;j++){
mapData[i][j]=smapdata[i].substr(j,1);
}
}
}

function CreateMap(){ //用dom来创建地图。
var x=30;
var y=30;
var cbox=0;
for (var i=0;i<15;i++){
for (var j=0;j<20;j++){
var oe=document.createElement("div");
oe.id="box"+i+"_"+j; //设定id规则以便后面程序访问。
oe.className="map"+mapData[i][j];
oe.style.pixelLeft=x;
oe.style.pixelTop=y;
gameArea.appendChild(oe);
x+=19;
}
y+=19;
x=30;
}
}

function move(dir){
var dx=0;
var dy=0;
if(dir=="Left") dx=-1;
if(dir=="Right") dx=1;
if(dir=="Up") dy=-1;
if(dir=="Down") dy=1;
if(mapData[spriteY+dy][spriteX+dx]=="1" ) return;
if(mapData[spriteY+dy][spriteX+dx]=="2" ) {
if(mapData[spriteY+dy*2][spriteX+dx*2]=="0" || mapData[spriteY+dy*2][spriteX+dx*2]=="3"){
if(mapData[spriteY+dy*2][spriteX+dx*2]=="3"){
mapData[spriteY+dy*2][spriteX+dx*2]="1";
winbox++;
if(winbox==3) win();
}
else mapData[spriteY+dy*2][spriteX+dx*2]="2";
mapData[spriteY+dy][spriteX+dx]="0";
eval("box"+(spriteY+dy)+"_"+(spriteX+dx)).style.backgroundColor='#333333';
eval("box"+(spriteY+dy*2)+"_"+(spriteX+dx*2)).style.backgroundColor='#3333FF';
spriteX+=dx;
spriteY+=dy;
sprite.style.pixelLeft+=dx*19;
sprite.style.pixelTop+=dy*19;
}
}else{
spriteX+=dx;
spriteY+=dy;
sprite.style.pixelLeft+=dx*19;
sprite.style.pixelTop+=dy*19;
}
}

function win(){
alert("OK 胜 利 !!!");
}

function fnKeydown(){
var key=event.keyCode;
switch(key){
case 37:
move("Left");
break;
case 39:
move("Right");
break;
case 38:
move("Up");
break;
case 40:
move("Down");
break;
}
return false;
}

function init(){
readMap();
CreateMap();
sprite.style.pixelLeft=49;
sprite.style.pixelTop=49;
spriteX=1;
spriteY=1;
}

document.onkeydown=fnKeydown;
</script>

<STYLE TYPE="text/css">
.map0{position:absolute;border:1px solid #cococo;width:20;height:20;background-color:#333333}
.map1{position:absolute;border:2px outset #FFFFFF;width:20;height:20;background-color:#999999}
.map2{position:absolute;border:1px solid #4078B0;width:20;height:20;background-color:#3333FF}
.map3{position:absolute;border:0px solid #999999;width:20;height:20;background-color:#006600}
.box{position:absolute;border:1px outset #ffffff;width:20;height:20;background-color:#0000cc}
}
</STYLE>

<body bgColor=#333333 onload="init()">
<div id=gameArea></div>
<div id="sprite" style="position:absolute"><img src="pic/0-2.gif" height=20 width=20></div>
</body>

2006-04-28 18:45
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

俄罗斯方块游戏
<HTML>
<HEAD>
<META NAME="Title" CONTENT="JScript Simple Tetris">

<TITLE>Simple Tetris</TITLE>
<style>
body {margin:0;background:black;}
td {height:20;width:20;}
#block_div {position:absolute;z-index:1;width:80;}
#table_div {position:absolute;z-index:0;width:320;}
#nblock_div {position:absolute;z-index:2;font:48 system;color:red;}
#title_div {position:absolute;left:326;top:7;font-size:22px;color:white}
#infobar_div {position:absolute;left:396;top:416;}
#infobar2_div {position:absolute;left:396;top:480;font-size:14px;color:white}
#infobar2_div a{color:99ccff;font:system;text-decoration:none}
</style>

<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--


if (document.all){
var n_width = 800;
var n_height = 600;
var n_left = Math.round( screen.width/2 ) - n_width/2;
var n_top = Math.round( screen.height/2 ) - n_height/2;
var n_IncStep = 20;
var curBlcok,nextBlock;
var arr_curBlock = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
var curX,curY;
var speed=1;
var maxspeed=9;
var clr_per_line=18;
var pause=0;
var gameover=0;
var colors = new Array("#999999","#0000FF","#80FFFF","#80FF80","#FFFF00","#FF8000","#FF00FF","#FF0000"
);
var cid;
var ncid;
var blocks = new Array("tt_O1","tt_T2","tt_Z1","tt_S1","tt_L1","tt_J1","tt_I2");
var bid;
var killedlines=0;

var tt_O1 = new Array(0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0);
var tt_O2 = new Array(0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0);
var tt_O3 = new Array(0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0);
var tt_O4 = new Array(0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0);

var tt_T1 = new Array(0,0,0,0,0,1,0,0,1,1,0,0,0,1,0,0);
var tt_T2 = new Array(0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0);
var tt_T3 = new Array(0,0,0,0,0,1,0,0,0,1,1,0,0,1,0,0);
var tt_T4 = new Array(0,0,0,0,0,1,0,0,1,1,1,0,0,0,0,0);

var tt_Z1 = new Array(0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0);
var tt_Z2 = new Array(0,0,0,0,0,0,1,0,0,1,1,0,0,1,0,0);
var tt_Z3 = new Array(0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0);
var tt_Z4 = new Array(0,0,1,0,0,1,1,0,0,1,0,0,0,0,0,0);

var tt_S1 = new Array(0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,0);
var tt_S2 = new Array(0,0,0,0,0,1,0,0,0,1,1,0,0,0,1,0);
var tt_S3 = new Array(0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0);
var tt_S4 = new Array(0,1,0,0,0,1,1,0,0,0,1,0,0,0,0,0);

var tt_L1 = new Array(0,1,0,0,0,1,0,0,0,1,1,0,0,0,0,0);
var tt_L2 = new Array(0,0,0,0,0,0,1,0,1,1,1,0,0,0,0,0);
var tt_L3 = new Array(0,0,0,0,0,1,1,0,0,0,1,0,0,0,1,0);
var tt_L4 = new Array(0,0,0,0,0,1,1,1,0,1,0,0,0,0,0,0);

var tt_J1 = new Array(0,0,1,0,0,0,1,0,0,1,1,0,0,0,0,0);
var tt_J2 = new Array(0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0);
var tt_J3 = new Array(0,0,0,0,0,1,1,0,0,1,0,0,0,1,0,0);
var tt_J4 = new Array(0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,0);

var tt_I1 = new Array(0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0);
var tt_I2 = new Array(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1);
var tt_I3 = new Array(0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0);
var tt_I4 = new Array(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1);

var table = new Array(
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)

}
else
alert("You need IE4+ to play Tetris!")

function dimension2(row,col,num){
var i = row * num + col;
return (this[i]);
}
Array.prototype.getd = dimension2;

function ShowBlock(x,y,block_type,color){
for (var i=0;i<block_tbl.rows.length;i++){
for (var j=0;j<block_tbl.rows(i).cells.length;j++){
var d2 = i * 4 + j;
if (block_type[d2]==1){
block_tbl.rows(i).cells(j).style.background = color;
}
else{
block_tbl.rows(i).cells(j).style.background = "";
}
}
}
block_div.style.pixelLeft=x;
block_div.style.pixelTop=y;
}

function ShowBlock1(x,y,block_type,color,obj_tabID,obj_divID){
for (var i=0;i<obj_tabID.rows.length;i++){
for (var j=0;j<obj_tabID.rows(i).cells.length;j++){
var d2 = i * 4 + j;
if (block_type[d2]==1){
obj_tabID.rows(i).cells(j).style.background = color;
}
else{
obj_tabID.rows(i).cells(j).style.background = "";
}
}
}
obj_divID.style.pixelLeft=x;
obj_divID.style.pixelTop=y;
}

function Change(inc){
var type = curBlock.substr(0,4);
var num = curBlock.substr(curBlock.length-1);
num = parseInt(num) + inc;
if (num>4||num<1) num -= 4*inc;
type += num;
eval("arr_tmp = " + type + ";");
if (CanMove(curX,curY,arr_tmp)){
curBlock = type;
eval("arr_curBlock = " + curBlock + ";");
eval("ShowBlock(block_div.style.pixelLeft,block_div.style.pixelTop," + curBlock + ",colors[" + cid + "]);");
}
}

function CanMove(x,y,block){
for (i=0;i<4;i++){
for (j=0;j<4;j++){
if (block.getd(i,j,4)&table.getd(y/n_IncStep+i,x/n_IncStep+j,16)) return false;
}
}
return true;
}

function NewBlock(){
curBlock = nextBlock;
cid = ncid;
bid = Math.round(Math.random()*(blocks.length-1));
ncid = Math.round(Math.random()*(colors.length-1));
nextBlock = blocks[bid];
eval("arr_curBlock = " + curBlock + ";");
eval("ShowBlock(120,0," + curBlock + ",colors[" + cid + "]);");
eval("arr_curBlock = " + curBlock + ";");
eval("ShowBlock1(466,116," + nextBlock + ",colors[" + ncid + "],nblock_tbl,nblock_div);");
}

function SaveBlock(){
for (i=0;i<4;i++){
for (j=0;j<4;j++){
table[(curY/n_IncStep+i)*16+curX/n_IncStep+j]|=arr_curBlock[i*4+j];
if (arr_curBlock[i*4+j]==1)
if ((curY/n_IncStep+i<21)&&(curX/n_IncStep+j>1)&&(curX/n_IncStep+j<14))
table_tbl.rows(curY/n_IncStep+i).cells(curX/n_IncStep+j).style.background = colors[cid];
if (table[(curY/n_IncStep+i)*16+curX/n_IncStep+j]!=1)
table_tbl.rows(curY/n_IncStep+i).cells(curX/n_IncStep+j).style.background = "black";
}
}
}

function DelLine(line){
for(i=line;i>0;i--){
for(j=2;j<14;j++){
table[i*16+j]=table[(i-1)*16+j];
}
}
table_tbl.deleteRow(line);
table_tbl.insertRow(0);
for (i=0;i<16;i++){
table_tbl.rows(0).insertCell();
if (i<2||i>13) table_tbl.rows(0).cells(i).style.background="navy";
}
killedlines++;
cll.innerText=parseInt(cll.innerText)+1;
}

function DelLines(){
var c,d,i,j;
d=0;
curY=block_div.style.pixelTop;
for(i=(curY/20+3);i>curY/20-1;i--){
c=0;
for(j=2;j<14;j++){
if (isNaN(table[i*16+j])||i==21) break;
c+=table[i*16+j];
}
if(c==12){
DelLine(i);
i++;
d++;
}
}
if (d>0)
sco.innerText=parseInt(sco.innerText)+d*d*36;
}

function Lucifer(){
for(var i=2;i<14;i++){
if (table[16+i]==1) return true;
}
return false;
}

function GameOver(){
gameover=1;
clearInterval(gameInterval);
block_div.innerHTML="";
for (i=0;i<21;i++){
for (j=2;j<14;j++){
setTimeout("table_tbl.rows(" + i + ").cells(" + j + ").style.background = colors[Math.round(Math.random()*7)];",16*i*j);
}
}
nblock_div.innerHTML = "Game Over";
}

function document_onkeydown() {
if (gameover==1) return;
with (block_div.style){
curX = pixelLeft;
curY = pixelTop;
switch (event.keyCode){
case 37:
if (CanMove(curX-n_IncStep,curY,arr_curBlock))
pixelLeft-=n_IncStep;
break;
case 38:
Change(1);
break;
case 39:
if (CanMove(curX+n_IncStep,curY,arr_curBlock))
pixelLeft+=n_IncStep;
break;
case 40:
if (CanMove(curX,curY+n_IncStep,arr_curBlock)){
pixelTop+=n_IncStep;
}
else{
SaveBlock();
DelLines();
if (Lucifer()){
GameOver();
return;
}
sco.innerText=parseInt(sco.innerText)+2;
NewBlock();
}
break;
case 32:
if (pause==0){
clearInterval(gameInterval);
pause=1;
}
else{
gameInterval=window.setInterval("Handle_Interval()",(maxspeed-speed+1)*60);
pause=0;
}
break;
case 90:
Change(1);
break;
case 88:
Change(-1);
break;
default:
}
}
}

function Handle_Interval(){
curX = block_div.style.pixelLeft;
curY = block_div.style.pixelTop;
if (CanMove(curX,curY+n_IncStep,arr_curBlock)){
block_div.style.pixelTop+=n_IncStep;
}
else{
SaveBlock();
DelLines();
if (Lucifer()){
GameOver();
return;
}
sco.innerText=parseInt(sco.innerText)+2
NewBlock();
}
if (killedlines>=clr_per_line){
killedlines-=clr_per_line;
if (speed<maxspeed)
speed++;
else
speed=maxspeed;
spd.innerText=speed;
clearInterval(gameInterval);
gameInterval=window.setInterval("Handle_Interval()",(maxspeed-speed+1)*60);
}
}
//-->
</SCRIPT>

<SCRIPT LANGUAGE=javascript FOR=document EVENT=onkeydown>
<!--
if (document.all)
document_onkeydown()
//-->
</SCRIPT>

</HEAD>

<BODY LANGUAGE=javascript>

<div id=block_div style="left:60;top:0">
<table id=block_tbl border=0 cellspacing=0 cellpadding=0>
<script>
if (document.all){
for (var i=0;i<4;i++){
document.write("<tr>");
for (var j=0;j<4;j++){
document.write("<td style=\"border:1 solid black;\"></td>");
}
document.write("</tr>");
}
}
</script>
</table>
</div>

<div id=nblock_div>
<table id=nblock_tbl border=0 cellspacing=0 cellpadding=0>
<script>
if (document.all){
for (var i=0;i<4;i++){
document.write("<tr>");
for (var j=0;j<4;j++){
document.write("<td style=\"height:40;width:40;border:1 outset black;\"></td>");
}
document.write("</tr>");
}
}
</script>
</table>
</div>

<div id=table_div>
<table id=table_tbl border=0 cellspacing=0 cellpadding=0>
<script>
if (document.all){
for (var i=0;i<22;i++){
document.write("<tr>");
for (var j=0;j<16;j++){
var d2 = i * 16 + j;
if (table[d2]==1)
document.write("<td bgcolor=navy></td>");
else
document.write("<td style=\"background:black;\"></td>");
}
document.write("</tr>");
}
}
</script>
</table>
</div>

<div id=title_div nowrap>Please input speed (1-9) to begin: <input type="text" size=8 id="speedin"> <button onClick="begintet()" id="but">Submit!</button></div>


<div id=infobar_div>
<table border=1 bordercolor=navy cellspacing=0 cellpadding=0>
<tr align=center>
<td style="color:99ccff;font:12 system;width:56;">Speed:</td>
<td style="color:red;font:12 system;" id=spd>1</td>
<td style="color:99ccff;font:12 system;width:86;">Total Score:</td>
<td style="color:red;font:12 system;" id=sco>0</td>
<td style="color:99ccff;font:12 system;width:96;">Cleared Lines:</td>
<td style="color:red;font:12 system;" id=cll>0</td>
</tr>
</table>
</div>

<SCRIPT ID=MainSection LANGUAGE=javascript>
<!--
if (document.all){
ncid = Math.round(Math.random()*(colors.length-1));
bid = Math.round(Math.random()*(blocks.length-1));
nextBlock = blocks[bid];
NewBlock();
}
function begintet(){
document.all.speedin.disabled=true
document.all.but.disabled=true
speed=parseInt(document.all.speedin.value);
if (isNaN(speed)||speed==null||speed>maxspeed||speed<1) speed=1;
spd.innerText=speed;
gameInterval=window.setInterval("Handle_Interval()",(maxspeed-speed+1)*60);
}


//-->
</SCRIPT>
</BODY>
</HTML>

2006-04-28 18:47
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

猜数字游戏
<SCRIPT LANGUAGE="JavaScript">

var js_mult1=3141
var js_mult2=5821
var js_m1=100000000
var js_m2=10000
var js_iseed=0
var js_iseed1=0
var js_iseed2=0


function random(n)
{
if (js_iseed == 0)
{
now = new Date()
js_iseed = now.getHours() + now.getMinutes() * 60
+ now.getSeconds() * 3600
}
js_iseed1 = js_iseed / js_m2
js_iseed2 = js_iseed % js_m2
var tmp = (((js_iseed2 * js_mult1 + js_iseed1 * js_mult2) % js_m2) *
js_m2 + (js_iseed2 * js_mult2)) % js_m1
js_iseed = (tmp + 1) % js_m1
return (Math.floor((js_iseed/js_m1) * n))
}


var myNumber = 0
var nGuesses = 0

function guessnum()
{
var response
var num = parseInt(document.forms[0].guess.value)

document.forms[0].guess.value = num // visual feedback in case of NaN

nGuesses++ // increase the guess count
response = "你猜的数字"

if (num < myNumber) response = response + "小了"
if (num > myNumber) response = response + "大了"
if (num == myNumber)
{
response = response + "猜对了!! 继续下一个数字吧."
nGuesses = 0
myNumber = random(100)+1
}
document.forms[1].result.value=response
document.forms[1].guesses.value=nGuesses
document.forms[0].guess.focus()
document.forms[0].guess.select()
return true
}

function giveup()
{
var response

nGuesses = 0
response = "这个数字是 " + myNumber +"。别灰心,猜下一个数字吧"
myNumber = random(100)+1
document.forms[1].result.value=response
document.forms[1].guesses.value=nGuesses
document.forms[0].guess.focus()
document.forms[0].guess.select()
}
</SCRIPT></HEAD>

<BODY bgcolor="ffffff" onLoad="document.forms[0].guess.focus(); document.forms[0].guess.select()">
<center>
<H2>猜数字游戏</H2><p><font size="2"><b>数字是1-100内的数字,随机显示,猜猜看</b></font><p>

<SCRIPT>
myNumber = random(100)+1
nGuesses = 0
</SCRIPT>

<FORM onSubmit="guessnum(); return false">
你猜的数字是: <INPUT TYPE="text" NAME="guess" SIZE=5>
<INPUT TYPE="button" VALUE=" 猜猜... " onClick="guessnum()">
<INPUT TYPE="button" VALUE=" 放弃 " onClick="giveup()">
</FORM>

<FORM><PRE>
次数: <INPUT TYPE="text" NAME="guesses" SIZE=3>
信息提示: <INPUT TYPE="text" NAME="result" SIZE=44>
</PRE></FORM>

2006-04-28 18:48
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

不好意思楼上的错了点
是这样的:
<HTML><HEAD>
<SCRIPT LANGUAGE="JavaScript">
var js_mult1=3141
var js_mult2=5821
var js_m1=100000000
var js_m2=10000
var js_iseed=0
var js_iseed1=0
var js_iseed2=0


function random(n)
{
if (js_iseed == 0)
{
now = new Date()
js_iseed = now.getHours() + now.getMinutes() * 60
+ now.getSeconds() * 3600
}
js_iseed1 = js_iseed / js_m2
js_iseed2 = js_iseed % js_m2
var tmp = (((js_iseed2 * js_mult1 + js_iseed1 * js_mult2) % js_m2) *
js_m2 + (js_iseed2 * js_mult2)) % js_m1
js_iseed = (tmp + 1) % js_m1
return (Math.floor((js_iseed/js_m1) * n))
}


var myNumber = 0
var nGuesses = 0

function guessnum()
{
var response
var num = parseInt(document.forms[0].guess.value)

document.forms[0].guess.value = num // visual feedback in case of NaN

nGuesses++ // increase the guess count
response = "你猜的数字"

if (num < myNumber) response = response + "小了"
if (num > myNumber) response = response + "大了"
if (num == myNumber)
{
response = response + "猜对了!! 继续下一个数字吧."
nGuesses = 0
myNumber = random(100)+1
}
document.forms[1].result.value=response
document.forms[1].guesses.value=nGuesses
document.forms[0].guess.focus()
document.forms[0].guess.select()
return true
}

function giveup()
{
var response

nGuesses = 0
response = "这个数字是 " + myNumber +"。别灰心,猜下一个数字吧"
myNumber = random(100)+1
document.forms[1].result.value=response
document.forms[1].guesses.value=nGuesses
document.forms[0].guess.focus()
document.forms[0].guess.select()
}
</SCRIPT></HEAD>

<BODY bgcolor="ffffff" onLoad="document.forms[0].guess.focus(); document.forms[0].guess.select()">
<center>
<H2>猜数字游戏</H2><p><font size="2"><b>数字是1-100内的数字,随机显示,猜猜看</b></font><p>

<SCRIPT>
myNumber = random(100)+1
nGuesses = 0
</SCRIPT>

<FORM onSubmit="guessnum(); return false">
你猜的数字是: <INPUT TYPE="text" NAME="guess" SIZE=5>
<INPUT TYPE="button" VALUE=" 猜猜... " onClick="guessnum()">
<INPUT TYPE="button" VALUE=" 放弃 " onClick="giveup()">
</FORM>

<FORM><PRE>
次数: <INPUT TYPE="text" NAME="guesses" SIZE=3>
信息提示: <INPUT TYPE="text" NAME="result" SIZE=44>
</PRE></FORM>

2006-04-28 18:49
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

贪吃蛇游戏!
<style>
.Food{background-color:red}
.Snake{background-color:blue}
</style>

<script>
var Rows=20
var Cells=30
var Num=15
var BorderWidth=5
var SpeedUp=5000

//创建地图
function CreateMap(){
BW=eval(Cells*Num+2*BorderWidth)
BH=eval(Rows*Num+2*BorderWidth)
document.body.innerHTML='<div id=MainMap style=position:absolute;left:'+(document.body.clientWidth-BW)/2+';top:'+(document.body.clientHeight-BH)/2+';width:'+BW+';height:'+BH+';border-width:'+BorderWidth+';border-style:inset;border-color:#0000cc></div>'
Map=new Array()
for(y=0;y<Rows;y++){
Map[y]=new Array()
for(x=0;x<Cells;x++){
Map[y][x]='0'
}
}
Sx=parseInt(Math.random()*Cells)
Sy=parseInt(Math.random()*Rows)
CreateSnake()
CreatFood()
AllDiv=MainMap.all.tags('DIV')
AllSpan=MainMap.all.tags('SPAN')
}


//创建食物的位置
function CreatFood(){
Fx=parseInt(Math.random()*Cells)
Fy=parseInt(Math.random()*Rows)
if(Map[Fy][Fx]=='0'){
MainMap.innerHTML+='<span style=position:absolute;left:'+Fx*Num+';top:'+Fy*Num+';width:'+Num+';height:'+Num+';overflow:hidden class=Food></span>'
Map[Fy][Fx]='F'
}
else CreatFood()
}


//创建蛇的位置
function CreateSnake(){
MainMap.innerHTML+='<div x='+Sx+' y='+Sy+' style=position:absolute;left:'+Sx*Num+';top:'+Sy*Num+';width:'+Num+';height:'+Num+';overflow:hidden class=Snake></div>'
Map[Sy][Sx]='S'
}


//主移动--判断蛇头前面的是什么
function Move(){
Sx+=GoX
Sy+=GoY
if(Sy<0||Sy>=Rows)Move1()
else{
SnakeFront=Map[Sy][Sx]
if(SnakeFront=='0')Move2()
else{
if(SnakeFront=='F')Move3()
else Move1()
}
}
}


//重新开始
function Move1(){
ReStart=confirm("Game Over,重新开始?")
if(ReStart)window.location.reload()
}

var Times=200

//蛇前是空地时

function Move2(){
Map[AllDiv[0].y][AllDiv[0].x]='0'
AllDiv[0].removeNode(true)
CreateSnake()
setTimeout('Move()',Times)
}

//蛇前面是食物时

function Move3(){
CreateSnake()
AllSpan[0].removeNode(true)
CreatFood()
setTimeout('Move()',Times)
}


//蛇越行越快
function oTimes(){
Times-=5
if(Times>5)setTimeout('oTimes()',SpeedUp)
}

document.onkeydown=KeyDown

//方向
function KeyDown(){
Key=event.keyCode
switch(Key){
case 37:Dir(-1,0);break//左
case 39:Dir(1,0);break//右
case 38:Dir(0,-1);break//上
case 40:Dir(0,1);break}//下
return false
}

var Star=0

function Dir(x,y){
GoX=x
GoY=y
if(Star==0){
oTimes()
Star=1
Move()
}
}


//开始时运行
onload=CreateMap
</script>

2006-04-28 18:51
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

游戏看谁围的圈数多!
<!--第一步:把如下代码加入<head>区域中-->

<script>
function ShowMenu(bMenu) {
document.all.idFinder.style.display = (bMenu) ? "none" : "block"
document.all.idMenu.style.display = (bMenu) ? "block" : "none"
idML.className = (bMenu) ? "cOn" : "cOff"
idRL.className = (bMenu) ? "cOff" : "cOn"
return false
}
</script>
<style>
<!--
A.cOn {text-decoration:none;font-weight:bolder}
#article {font: 12pt Verdana, geneva, arial, sans-serif; background: white; color: black; padding: 10pt 15pt 0 5pt}
#article P.start {text-indent: 0pt}
#article P {margin-top:0pt;font-size:10pt;text-indent:12pt}
#article #author {margin-bottom:5pt;text-indent:0pt;font-style: italic}
#pageList P {padding-top:10pt}
#article H3 {font-weight:bold}
#article DL, UL, OL {font-size: 10pt}
-->
</style>
<script>
<!--
function addList(url,desc) {
if ((navigator.appName=="Netscape") || (parseInt(navigator.appVersion)>=4)) {
var w=window.open("","_IDHTML_LIST_","top=0,left=0,width=475,height=150,history=no,menubar=no,status=no,resizable=no")
var d=w.document
if (!w._init) {
d.open()
d.write("<TITLE>Loading...</TITLE><EM>Loading...</EM>")
d.close()
d.location.replace("/assist/listing.asp?url="+escape(url)+"&desc="+escape(desc))
w.opener=self
window.status="Personal Assistant (Adding): " + desc
} else {
window.status=w.addOption(url,desc)
w.focus()
}
}
else
alert("Your browser does not support the personal assistant.")
return false
}
// -->
</script>

<style>
#board {font-family: arial}
.dot {position: absolute; width: 5px; height: 5px; font-size: 0pt; background: black}
#line {position: absolute; font-size: 0pt; height: 5px}
.p1 {position: absolute; font-size: 0pt;background: navy}
.p2 {position: absolute; font-size: 0pt; background: red}
.p1B {position: absolute; font-size: 8pt; color: navy;text-align: center; font-weight: bold}
.p2B {position: absolute; font-size: 8pt; color: red; text-align: center; font-weight: bold}
</style>
<style type="text/css">
<!--
body { font-family: "宋体"; font-size: 9pt; margin-top: 0px; margin-left: 0px; margin-right: 0px}
A { COLOR: black; FONT-SIZE: 13px; FONT-WEIGHT: 400; TEXT-DECORATION: none }
A:hover { COLOR: red; FONT-SIZE: 13px; FONT-WEIGHT: 400; TEXT-DECORATION: underline }
a:active { font: 9pt "宋体"; cursor: hand; color: #FF0033 }

-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var timerRunning = false;
var timezone = "Greenwich Mean Time";
var adjust = 0;

function timeCheck(tzone, diff) {
if (timerRunning) {
clearTimeout(updatetime);
timerRunning = false; }
gmtOffset=eval(diff+adjust);
timezone = tzone;
checkDateTime();
}

function checkDateTime () {
var today = new Date();
var year = today.getYear() + 1900;
var month = today.getMonth()+1;
var date = today.getDate();
var day = today.getDay();
var hour = today.getHours();
var minute = today.getMinutes();
var second = today.getSeconds();

var lastSat = date - (day+1);
while (lastSat < 32) lastSat+=7;
if (lastSat > 31) lastSat+=-7;
var firstSat = date - (day+1);
while (firstSat > 0) firstSat+=-7;
if (firstSat < 1) firstSat+=7;
if ((((month == 4) && (date >= firstSat)) || month > 4) &&
(month < 11 || ((month == 10) && day <= lastSat))) adjust += 60;
yourOffset = (new Date()).getTimezoneOffset();
yourOffset = yourOffset + adjust;

var xx = navigator.appName
var xy = navigator.appVersion;
xy = xy.substring(0,1);
if ((xy == 4) && (xx == "Netscape")) yourOffset = yourOffset+adjust;
if ((((month == 4) && (date > 20)) || month > 4) && (month < 11 || ((month == 10) &&
day < 30))) adjust -= 60;

ourDifference = eval(gmtOffset - yourOffset);
var half = eval(ourDifference % 60);
ourDifference = Math.round(ourDifference / 60);
hour = eval(hour - ourDifference);
var m = new Array("",
"Jan","Feb","Mar",
"Apr","May","Jun",
"Jul","Aug","Sept",
"Oct","Nov","Dec");
var leap = eval(year % 4);

if ((half == -30) || (half == 30)) minute += 30;
if (minute > 59) minute -= 60, hour++;
if (minute < 0) minute += 60, hour--;
if (hour > 23) hour -= 24, date += 1;
if (((month == 4) || (month == 6) ||
(month == 9) || (month == 11)) && (date==31)) date = 1, month ++;
if (((month == 2) && (date > 28)) && (leap != 0)) date = 1, month ++;
if ((month == 2) && (date > 29)) date = 1, month++;
if (hour < 0) hour += 24, date --;
if ((date == 32) && (month == 12)) month = m[1], date = 1, year++;
if (date == 32) date = 1, month++;
if ((date < 1) && (month == 1)) month= m[12], date = 31, year--;
if (date < 1) date = 31, month --;
if (((month == 4) || (month == 6) ||
(month== 9) || (month == 11)) && (date == 31)) date = 30;
if ((month == 2) && (date > 28)) date = 29;
if (((month == 2) && (date > 28)) && (leap != 0)) date=28;
for (i=1; i<13; i++) {
if (month == i) {
month = m[i]; break;
}
}

var dateTime = hour;
dateTime = ((dateTime < 10) ? "0":"") + dateTime;
dateTime = " " + dateTime;
dateTime += ((minute < 10) ? ":0" : ":") + minute;
dateTime += ((second < 10) ? ":0" : ":") + second;
dateTime += (hour >= 12) ? " PM, " : " AM, ";
dateTime += month + " " + date + ", " + year;

document.clock.zonetime.value = dateTime;
document.clock.zonename.value = timezone;
updatetime=setTimeout("checkDateTime()", 900);
timerRunning = true;
}
// End -->
</SCRIPT>

<!--第二步:把如下代码加入<body>区-->

<table CELLPADDING="0" CELLSPACING="0" BORDER="0" width="509">
<tr>
<td WIDTH="10"></td>
<td valign="top" WIDTH="499" ID="article"><p class="start" STYLE="text-align: left"><font
size="+2" style="font-weight:bold;font-size: 14pt"><b>看谁围的框子多?</b></font></p>
<p>这是一个双人游戏,蓝色的先行,看谁围的框子多,谁就赢。</p>
<p STYLE="margin-top: 5pt"><script>
/* DHTML Dots is copyright 1998 insideDHTML.com, LLC. All rights reserved.
DHTML Dots cannot be reproduced in any manner without prior consent from insideDHTML.com */

var scale= 25
var size = 5

var totalSize = ((size+1)*scale) + 6
var cache = new Object()
var move=0,point=0
var player = true

function initCache() {
cache.x = 0
cache.y = 0
cache.red = 0
cache.navy = 0
move=0,point=0
}

function updateScore() {
document.all.red.innerText = cache.red
document.all.navy.innerText = cache.navy
if ((cache.red+cache.navy)==((size-1)*(size-1))) {
board.onclick = null
document.all.message.innerText = "Game Over!"
}

}

function fillPos(x,y) {
document.all.board.insertAdjacentHTML("beforeEnd","<DIV class=" + (player ? "p1B" : "p2B") + " ID=\"point"+point+"\">" + (player ? "N" : "R") + "</DIV>")
var el = document.all["point"+point].style
el.pixelTop = (y*scale)+5
el.pixelLeft = (x*scale)+5
el.pixelWidth = scale - 5
el.pixelHeight = scale - 5

}

function checkBoard(x,y,dir, player) {
var piece=0
if ("vertical"==dir) {
if ((x==size) || (x>1)) {
var bPos = boardArray[x-1][y]
var nextV = boardArray[x-1][y+1]
if ((bPos["vertical"]) && (bPos["horizontal"]) && (nextV["horizontal"])) {
point++
piece++
fillPos(x-1,y)
}
}
if ((x==1) || (x<size)) {
var nextV = boardArray[x+1][y]
var nextH = boardArray[x][y+1]
if ((nextV["vertical"]) && (nextH["horizontal"]) && (boardArray[x][y]["horizontal"])) {
point++
piece++
fillPos(x,y)
}
}
}
else {
if ((y==size) || (y>1)) {
var nextV = boardArray[x+1][y-1]
var bPos = boardArray[x][y-1]
if ((bPos["vertical"]) && (bPos["horizontal"]) && (nextV["vertical"])) {
point++
piece++
fillPos(x,y-1)
}
}
if ((y==1) || (y<size)) {
var nextV = boardArray[x+1][y]
var nextH = boardArray[x][y+1]
if ((nextV["vertical"]) && (nextH["horizontal"]) && (boardArray[x][y]["vertical"])) {
point++
piece++
fillPos(x,y)
}
}
}
if (piece>0) {
if (player)
cache.navy+=piece
else
cache.red+=piece
document.all.message.innerText = "Score! Go Again."
updateScore()
return player
}
else
return !player

}

function doMouseMove() {
if (event.srcElement.className!="dot") {
var x = Math.floor(event.offsetX / scale)
var y = Math.floor(event.offsetY / scale)
var dirX = (event.offsetX % scale)
var dirY = (event.offsetY % scale)
if ((x<size+1) && (y<size+1) && (y>0) && (x>0)) {
if (dirX>=dirY) {
if (x<size) {
line.style.pixelHeight = 5
line.style.pixelWidth = scale - 5
line.style.pixelTop = (y * scale)
line.style.pixelLeft = (x * scale) + 5
cache.direction = "horizontal"
}
} else
{
if (y<size) {
line.style.pixelWidth = 5
line.style.pixelHeight = scale - 5
line.style.pixelTop = (y * scale) + 5
line.style.pixelLeft = x * scale
cache.direction = "vertical"
}
}
cache.x = x
cache.y = y
}
}

}

function doClick() {

if (cache.x==0) return
if (boardArray[cache.x][cache.y][cache.direction])
document.all.message.innerText="That spot is taken! Choose again"
else {
document.all.board.insertAdjacentHTML("beforeEnd","<DIV class=" + (player ? "p1" : "p2") + " ID=move"+move+"></DIV>")
var el = document.all["move"+move]
el.style.top = line.style.top
el.style.left = line.style.left
el.style.width = line.style.width
el.style.height = line.style.height
boardArray[cache.x][cache.y][cache.direction]=true
var nextPlayer = checkBoard(cache.x,cache.y,cache.direction, player)
if (nextPlayer!=player) {
player = nextPlayer
if (player) {
document.all.message.innerText = "Navy players turn"
line.style.border = "1px navy solid"
}
else {
document.all.message.innerText = "Red players turn"
line.style.border = "1px red solid"
}
}
}


move++
}

function buildDiv(x,y, scale) {
return ("<DIV CLASS=dot STYLE=\"top:" + (x*scale) + "; left: " + (y*scale) + "\"></DIV>")
}

var boardArray = new Object


function buildBoard() {
initCache()
board = ("<DIV ID=line STYLE=\"border: 1px navy solid; width: 0; height: 0\"></DIV>")
boardArray = new Object()
for (var x=1; x < size+1; x++) {
boardArray[x] = new Object()
for (var y=1; y < size+1; y++) {
boardArray[x][y] = new Object
boardArray[x][y]["vertical"] = false
boardArray[x][y]["horizontal"] = false
board+=(buildDiv(x,y, scale))
}
}

return board
}

function createGame() {
size=parseInt(document.all.setSize.value)
if (size>12)
size=12
if (size<3)
size=3
document.all.setSize.value = size
document.all.board.innerHTML = buildBoard()
document.all.board.onclick = doClick
totalSize = ((size+1)*scale) + 6
document.all.board.style.pixelWidth = totalSize
document.all.board.style.pixelHeight = totalSize
document.all.message.innerText = "Navy player goes first. Good Luck!"
updateScore()
}
document.write("<DIV ID=board STYLE=\"position: relative; height: "+ totalSize + "; width:" + totalSize + "; border: 1px black solid\">" + buildBoard() + "</DIV>")
document.all.board.onmousemove = doMouseMove
document.all.board.onclick = doClick

</script> </p>
<div STYLE="margin-left: 10pt; margin-top: 5pt"><p class="start" ID="message">Navy player
goes first. Good Luck!</p>
<dd><br>
<table border="1" width="100">
<tr>
<td style="color: red"><b>Red</b></td>
<td ID="red">0</td>
</tr>
<tr>
<td style="color: navy"><b>Navy</b></td>
<td ID="navy">0</td>
</tr>
</table>
<p><br>
</p>
<table width="200">
<tr>
<td>游戏大小: </td>
<td><input TYPE="Text" VALUE="5" ID="setSize" SIZE="2"></td>
</tr>
<tr>
<td COLSPAN="2" align="center"><input TYPE="button" ONCLICK="createGame()"
VALUE="New Game"></td>
</tr>
</table> <p CLASS="copyright"> </p>
</dd>
</div></td>
</tr>
</table>

2006-04-28 18:52
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

选择你喜欢的女孩子类型!
<!--第一步:把如下代码加入<head>区域中-->
<SCRIPT language=JavaScript>
<!--
function processForm(form){
if (form.c1[0].checked==1) form.answer.value="把双手放在胸口前往往给人一种害羞、紧张、自我保护的感觉。选择这个姿势的男性就是喜欢这种含羞答答、在紧张时不自觉会手足无措,稍具气质及矜持的女性。";
if (form.c1[1].checked==1) form.answer.value="两手垂下给人一种自然、顺从的感觉。选择这个姿势的男性会喜欢不造作、不刻意掩饰自己及带点天真的女性。";
if (form.c1[2].checked==1) form.answer.value="两手张开给人一种接纳、包容的感觉。选择这个姿势的男性会倾向喜欢较年长、或是能给予他像母亲的爱般温暖的女性。";
}
//-->
</SCRIPT>

<!--第二步:把如下代码加入<body>区域中-->


<TABLE border=0 cellPadding=4 cellSpacing=0 height=78 width=500>
<TBODY>
<TR>
<TD align=middle height=38 width=561><SPAN
style="FONT-SIZE: 6pt">◇◆◇◆◇</SPAN><SPAN
style="FONT-SIZE: 12pt"><STRONG>哪一类型女仔最吸引你</STRONG></SPAN><SPAN
style="FONT-SIZE: 6pt">◇◆◇◆◇</SPAN></TD></TR></TBODY></TABLE></DIV>
<FORM name=see>
<DIV align=left>
<TABLE border=0 cellPadding=10 cellSpacing=0 height=223 width=517>
<TBODY>
<TR>
<TD height=1 width=517>
<DIV align=left>
<P>假如圣母玛莉亚赤裸站在你面前,你认为她的双手会放在那儿?</P></DIV>
<DIV align=left>
<P><INPUT name=c1 type=radio value=1>放在胸口前。<BR><INPUT name=c1 type=radio
value=3>两手垂下。<BR><INPUT name=c1 type=radio value=V1>两手张开成V字形。
</P></DIV></TD></TR>
<TR>
<TD align=middle height=27 width=517><INPUT onclick=processForm(this.form) style="FONT-FAMILY: 宋体; FONT-SIZE: 9pt" type=button value=已选好,看看结论!></TD></TR>
<TR>
<TD align=middle height=-12 width=517><TEXTAREA cols=47 name=answer rows=5 style="COLOR: rgb(255,0,0); FONT-FAMILY: 宋体; FONT-SIZE: 9pt; LINE-HEIGHT: 15px">

2006-04-28 18:55
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

在状态栏显示停留时间
要完成此效果把如下代码加入到<body>区域中

<script language="Javascript">
<!--
var x = 0
var speed = 120
var text = "欢迎光临细溪驿站!"
var course = 120
var text2 = text

function Scroll() {
window.status = text2.substring(0, text2.length)

if (course < text2.length) {
setTimeout("Scroll2()", speed)
}

else {
text2 = " " + text2

setTimeout("Scroll()", speed);
}
}

function Scroll2() {
window.status = text2.substring(x, text2.length)

if (text2.length - x == text.length) {
text2 = text
x = 0

setTimeout("Scroll()", speed);
}

else {
x++
setTimeout("Scroll2()", speed);
}
}

Scroll()
//-->
</script>

2006-04-28 18:57
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

字符在状态栏中缓慢移动
要完成此效果把如下代码加入到<head>区域中

<SCRIPT LANGUAGE="javascript">
function wh_showStatus(){
if (wh_StatusType == "left") {
wh_StatusText = " " + wh_StatusText;
}
else
if (wh_StatusType == "right") {
wh_StatusText = wh_StatusText.substring(1,wh_StatusText.length);
}
if (wh_StatusText == "" || wh_StatusText.length > 80) {
wh_StatusText = "Welcome to JavaScript Fairyland";
if (wh_StatusType == "right") {
while (wh_StatusText.length < 80) wh_StatusText = " " +

wh_StatusText;
}
}
status = wh_StatusText;
setTimeout("wh_showStatus()",wh_StatusSpeed);
}
wh_StatusText = "Welcome to 细 溪 驿 站";
wh_StatusSpeed = 1000;
wh_StatusType = "left";
if (wh_StatusType == "right") {
while (wh_StatusText.length < 80) wh_StatusText = " " +

wh_StatusText;
}
setTimeout("wh_showStatus()",wh_StatusSpeed);
</SCRIPT>

2006-04-28 18:58
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

背景不听变化
脚本说明:
第一步:把如下代码加入<body>区域中
<SCRIPT language=javascript><!--
var pos=10;function initArray(){this.length=initArray.arguments.length;
for(var i=0;i<this.length;i++){this[i]=initArray.arguments[i];}}
var col=new initArray("4b","5b","8b","8b");
col[0]="yellow";col[1]="coral";col[2]="orange";col[3]="red";
col[4]="greenyellow";col[5]="lime";col[6]="turquoise";col[7]="coral";
col[8]="blueviolet";col[9]="violet";
function chgCol(){pos++;if(pos<0||pos>9){pos=0;}document.bgColor=col[pos];
setTimeout("chgCol()",3000);/*这里你可以改变时间间隔.*/
}
var yourwords="不断变化背景色彩";var buffer1=" ";
var buffer2=" ";
var message1=buffer1+yourwords+buffer2;
var dir="left";var speed=150;function pingpong(){
if(dir=="left")
{message2=message1.substring(2,message1.length)+" ";
window.status=message2;setTimeout("pingpong();",speed);message1=message2;
if(message1.substring(0,1)=="*")dir="right";}
else{message2=" "+message1.substring(0,message1.length-2);
window.status=message2;setTimeout("pingpong();",speed);
message1=message2;if(message1.substring(message1.length-1,message1.length)=="*")dir="left";}}//
-->
</SCRIPT>


第二步:把<body>改为
<body bgColor=#ffffff onload="chgCol(); pingpong();">

2006-04-28 18:59
快速回复:无聊找了点网页特效代码!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027623 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved