stoneme
小狐狸
小狐狸
  • UID8518
  • 注册日期2005-09-10
  • 最后登录2005-09-10
  • 发帖数3
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
阅读:4017回复:1

有一段JS在firxfox里怎么也运行不了,改也改不成,哪位大侠帮帮看应该改哪

楼主#
更多 发布于:2005-09-10 09:52
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>世界古代三大不可思议之二:独立钻石棋</title>
<STYLE>
.drag {
	CURSOR: hand; POSITION: relative
}
</STYLE>
<script language=javascript>
</script>

</head>
<script language=javascript>
//self.moveTo(100,100);
self.resizeTo(430,500);
</script>
<body leftmargin=0 topmargin=0>
<div style='position:absolute;width:360;height:360;
top:0;left:0;visibility:visible;z-index:0;background-color: #ffffff'>
</div>
<div style='position:absolute;width:100;height:20;left:10;top:10;z-index=2'>
<center>
<table><tr>
<td align=center><input disabled=true type=button value="←" name="pre" onclick="step_pre();"></td>
<td align=center><input disabled=true type=button value="→" name="next" onclick="step_next();"></td>
</tr>
<tr>
<td align=center><input  type=button value="榜" onclick="javascript:window.open('success.php','mark');"></td>
<td align=center><input  type=button value="帮" onclick="javascript:window.open('readme.html','mark');"></td>
<!--
<td style='font-size:9pt'><a href=success.php target=mark>排行</a></td>
<td style='font-size:9pt'><a href=readme.txt target=mark>说明</a></td>
-->
</tr>
<tr>
<td style='font-size:9pt' colspan=2 align=center><input  type=button value="重开始" onclick="javascript:init();"></td>
</tr>
</table>
</center>
</div>
<img src=img/qp.png style='position:absolute;width:350;height:350;top:26;left:26;z-index:0'>
<!--
<img src=img/line.bmp style='position:absolute;width:100;height:1;top:50;left:150'>
<img src=img/line.bmp style='position:absolute;width:100;height:1;top:100;left:150'>
<img src=img/line.bmp style='position:absolute;width:300;height:1;top:150;left:50'>
<img src=img/line.bmp style='position:absolute;width:300;height:1;top:200;left:50'>
<img src=img/line.bmp style='position:absolute;width:300;height:1;top:250;left:50'>
<img src=img/line.bmp style='position:absolute;width:100;height:1;top:300;left:150'>
<img src=img/line.bmp style='position:absolute;width:100;height:1;top:350;left:150'>
<img src=img/line.bmp style='position:absolute;width:1;height:100;top:150;left:50'>
<img src=img/line.bmp style='position:absolute;width:1;height:100;top:150;left:100'>
<img src=img/line.bmp style='position:absolute;width:1;height:300;top:50;left:150'>
<img src=img/line.bmp style='position:absolute;width:1;height:300;top:50;left:200'>
<img src=img/line.bmp style='position:absolute;width:1;height:300;top:50;left:250'>
<img src=img/line.bmp style='position:absolute;width:1;height:100;top:150;left:300'>
<img src=img/line.bmp style='position:absolute;width:1;height:100;top:150;left:350'>
-->
<SCRIPT language=JavaScript>
for(i=1;i<=32;i++)
{
	document.write("<img src=img/"+i+".png class=drag id='T"+i+"' style='position:absolute;width:15;height:15;top:0;left:0'>");
}
//This 3 function define a stack to save data
function stack(){
	this.fp=0;
	this.arr = new Array();
	this.arr[0]=-1;
	this.push=push
	this.pop =pop
}
function push(tc){
	this.fp++;
	this.arr[this.fp]=tc;
	return true;
}
function pop(){
	if(this.fp == 0)return false;
	return this.arr[this.fp--];
}

function emp(chess1,chess2,from,to){
	this.chess1=chess1;
	this.chess2=chess2;
	this.from=from;
	this.to=to;
}


//step_pre and step_next function make a way to pre a move or to next
//←↑→↓

function step_pre(){
	if(tmpre = next.pop()){
		if(next.fp == 0)document.all.pre.disabled=true;
		if(pre.fp == 0) document.all.next.disabled=false;
		pre.push(tmpre);
		c1 = tmpre.chess1;
		c2 = tmpre.chess2;
		c3 = tmpre.from;
		c4 = tmpre.to;
		document.all['T'+c2].style.zIndex=1;
		shi[c3]=shi[c4];shi[c4]=0;shi[(c3+c4)/2]=c2;
		c5 = Math.floor(c3/7);
		c4 = c3%7-1;
		if(c4<0){c4=6;c5--;}
		document.all['T'+c1].style.pixelLeft = c4*50+basex;
		document.all['T'+c1].style.pixelTop = c5*50+basey;
	}
	return true;
}

function step_next(){
	if( tmpre = pre.pop() ){	
		if(next.fp == 0){document.all.pre.disabled = false;}
		if(pre.fp == 0) document.all.next.disabled=true;
		next.push(tmpre);
		c1 = tmpre.chess1;
		c2 = tmpre.chess2;
		c3 = tmpre.from;
		c4 = tmpre.to;
		document.all['T'+c2].style.zIndex=-1;
		shi[c4]=shi[c3];shi[c3]=0;shi[(c3+c4)/2]=0;
		
		document.all['T'+c1].style.pixelLeft = (c4%7-1)*50+basex;
		document.all['T'+c1].style.pixelTop = Math.floor(c4/7)*50+basey;
	}
	return true;
}



//sen is a percent of strongth 20% to 40% is good idea
var dragapproved=false
var z
var temp1,temp2,step
var step = 0;
var basex=45;
var basey=45;
var gred=0;

var next,pre;
var tchess;
var shi=new Array(7*7);
function init(){
	next = new stack();
	pre  = new stack();
	dragapproved = false;
	for(i=1;i<=7;i++)for(j=1;j<=7;j++)shi[(j-1)*7+i]=-1;
	for(i=1;i<=3;i++)shi[i+2]=i;
	for(i=4;i<=6;i++)shi[i+6]=i;
	for(i=7;i<=16;i++)shi[i+8]=i;
	shi[25]=0;
	for(i=17;i<=26;i++)shi[i+9]=i;
	for(i=27;i<=29;i++)shi[i+11]=i;
	for(i=30;i<=32;i++)shi[i+15]=i;
	for(i=1;i<=7;i++)for(j=1;j<=7;j++)if(shi[(j-1)*7+i]>0){
		document.all["T"+shi[(j-1)*7+i]].style.top  = (j-1)*50 + basey;
		document.all["T"+shi[(j-1)*7+i]].style.left = (i-1)*50 + basex;
		document.all["T"+shi[(j-1)*7+i]].style.zIndex = 1;
		
		//document.write("<img src=img/ball.gif class=drag id='T"+shi[(j-1)*7+i]+"' style='position:absolute;width:15;height:15;top:"+((j-1)*50 + basey)+";left:"+((i-1)*50 + basex)+"'>");
	}
}
//rulemove 已经确定合乎规则的移动
//←↑→↓↖↗↘↙
function canmove(){
	for(i=0;i<7;i++)for(j=1;j<=5;j++)
	{
		if(
		   ((shi[i*7+j] >0) && (shi[i*7+j+1]>0) && (shi[i*7+j+2] == 0))
		|| ((shi[i*7+j]==0) && (shi[i*7+j+1]>0) && (shi[i*7+j+2]  > 0))
		|| ((shi[(j-1)*7+i+1] >0) && (shi[j*7+i+1]>0) && (shi[(j+1)*7+i+1]== 0))
		|| ((shi[(j-1)*7+i+1]==0) && (shi[j*7+i+1]>0) && (shi[(j+1)*7+i+1] > 0))
		)return true;
	}
	/*
	for(i=1;i<=7;i++)for(j=1;j<=7;j++){
		si=j*7+i-7
		if(shi[si]>0){
			if((si<46 && shi[si+1]>0 && shi[si+2]==0)
			 ||(si>4 && shi[si-1]>0 && shi[si-2]==0)
			 ||(si>14 && shi[si-7]>0 && shi[si-14]==0)
			 ||(si<36 && shi[si+7]>0 && shi[si+14]==0)
			)return true;
		}
	}
	*/
	return false;
}
function countit(){
	count=0;
	for(i=1;i<=7;i++)for(j=1;j<=7;j++){
		if(shi[j*7+i-7]>0)count++;
	}	
	return count;
}
function rule(){
//  O---O---O
//  ti  |  si
//     (ti+si)/2
//  ti--->>>si from ti to si delete shi[(ti+si)/2]
	sx=Math.round(z.style.pixelLeft/50)
	sy=Math.round(z.style.pixelTop/50)
	si=sy*7+sx-7;
	if((shi[si]==0)&&(((si-ti)==2)||((si-ti)==-2)||((si-ti)==14)||((si-ti)==-14))&&(shi[(si+ti)/2]>0)){
		if(next.fp==0)document.all.pre.disabled=false;
		next.push(new emp(shi[ti],shi[(si+ti)/2],ti,si))
		document.all['T'+shi[(si+ti)/2]].style.zIndex=-1;
		document.all['T'+shi[ti]].style.pixelLeft = sx*50+basex-50;
		document.all['T'+shi[ti]].style.pixelTop = sy*50+basey-50;
		shi[si]=shi[ti];
		shi[ti]=0;
		shi[(si+ti)/2]=0;
		return true;
	}
	return false;
}
function move(){
	if (event.button==1&&dragapproved){
		z.style.pixelLeft=temp1+event.clientX-x
		z.style.pixelTop=temp2+event.clientY-y
		return false
	} else if( (! dragapproved) && event.srcElement.className=='drag') {
		document.onmousemove='';
		if(!rule()){
			z.style.pixelLeft=temp1
			z.style.pixelTop=temp2
		}else{
			if(!canmove()){
				count=countit();
				if(count==1){
					if(shi[25]>0)mark=0;
					else mark=1;
				}else if(count<=6){
					mark=count;
				}else{
					alert("太差了," + name + "再来吧!");
					//self.refresh();
					//window.location.href='./';
					init();
					return;
				}
				name=document.all.save.name.value;
				name=prompt("你已经被记入排行榜,请输入你的姓名:",name);
				if(name == "" || name == "无名" || name == null || name == "null")
				{
					init();
					return ;
				}
				strp = gred;
	
				for(i=1;i<=next.fp;i++)
				{
					strp += "," + next.arr[i].chess1 + "," + next.arr[i].chess2 + "," + next.arr[i].from + "," + next.arr[i].to ;
				}
				//alert(strp); 
				document.all.save.step.value = strp;	
				document.all.save.name.value=name
				document.all.pre.disabled=true
				document.all.save.mark.value=mark;
				//window.open('','mark','width=400');
				document.save.submit();
				init();
			}
		}
		z.style.zIndex=1;
	}
}

function drags(){
	if (!document.all)return
	if (event.srcElement.className=="drag"){
		dragapproved=true
		z=event.srcElement
		temp1=z.style.pixelLeft
		temp2=z.style.pixelTop
		x=event.clientX
		y=event.clientY
		tx=Math.round(temp1/50)
		ty=Math.round(temp2/50)
		ti=ty*7+tx-7
		tchess=shi[ti]
		//self.status=tchess;
		z.style.zIndex=2;
		document.onmousemove=move
	}
}

document.onmousedown=drags
document.onmouseup=new Function("dragapproved=false")
init();
</SCRIPT>
<form method=post action='success.php' target='mark' name='save'>
<input type=hidden name=type value=duli>
<input type=hidden name=step value=>
<input type=hidden name=mark value=>
<input type=hidden name=name value='无名'>
</form>
</body>

</html>

这是我写的独立钻石棋的程序,象document.nomousedown=drags怎么改成MF也能用?
------+===+-------
carlos26_h
小狐狸
小狐狸
  • UID9244
  • 注册日期2005-10-13
  • 最后登录2005-12-30
  • 发帖数2
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
1楼#
发布于:2005-09-10 09:52
if (!document.all)return
will return in fireFox
  
if (event.srcElement.className=="drag"){
should use eventObj in NN
游客

返回顶部