2016-04-10 3 views
-2

ここにコードがあります。このウェブページはレモンを落としてバウンスしていると思われますが、私は間違いをして縫い目を見つけることができず、見つけられません

私はそれがあまりにも長くそれを見つめているので、私が見ることができないものが主な問題だと思う。私はそれのロジックを見てきたし、それはすべて正常に見えるが、私はどこかにいくつかのエラーを行っている必要があります(私はエラーが2番目のスクリプトでは、主に最初ではありません推測している知っている。

<SCRIPT LANGUAGE="JavaScript1.2"> 

<!-- Begin 
function BrowserCheck() { 
var b = navigator.appName; 
if (b == "Netscape") this.b = "NS"; 
else if (b == "Microsoft Internet Explorer") this.b = "IE"; 
else this.b = b; 
this.v = parseInt(navigator.appVersion); 
this.NS = (this.b == "NS" && this.v>=4); 
this.NS4 = (this.b == "NS" && this.v == 4); 
this.NS5 = (this.b == "NS" && this.v == 5); 
this.IE = (this.b == "IE" && this.v>=4); 
this.IE4 = (navigator.userAgent.indexOf('MSIE 4')>0); 
this.IE5 = (navigator.userAgent.indexOf('MSIE 5')>0); 
if (this.IE5 || this.NS5) this.VER5 = true; 
if (this.IE4 || this.NS4) this.VER4 = true; 
this.OLD = (! this.VER5 && ! this.VER4) ? true : false; 
this.min = (this.NS||this.IE); 
} 
is = new BrowserCheck(); 
// End --> 
</script> 
</HEAD> 


<BODY> 

<center> 
Click on the screen to drop lemon<br> 
<div id="staticBall" style="position:relative;visibility:visible"> 
<img src="lemon.png" height=30 width=30 alt="Static lemon"> 
</div> 
</center> 
<div id="ball" style="visibility:hidden; position:absolute; left:100;  top:10; height:34; width:34"> 
<img src="lemon.png" height=30 width=30 alt="Bouncing lemon"> 
</div> 

<script language="Javascript1.2"> 
<!-- Begin 
iter = 0; 
setId = 0; 
down = true; 
up = false; 
bouncingBall = (is.VER5) ? document.getElementId("ball").style 
: (is.NS) ? document.layers["ball"] 
: document.all["ball"].style; 
stillBall = (is.VER5) ? document.getElementId("staticBall").style 
: (is.NS) ? document.layers["staticBall"] :   document.all["staticBall"].style; 
winH = (is.NS) ? window.innerHeight - 55 : document.body.offsetHeight - 55; 
document.onmouseup = buttonUp; 
if (is.NS4) 
document.captureEvents(Event.MOUSEUP); 
function buttonUp(e) { 
if (((is.NS) ? e.which : event.button) != 1) return true; 
if (setId != 0) clearInterval(setId); 
bouncingBall.visibility="visible"; 
stillBall.visibility="hidden"; 
bouncingBall.left = (is.NS) ? e.pageX - 15 : event.offsetX - 15; 
bouncingBall.top = (is.NS) ? e.pageY - 15 : event.offsetY - 15; 
iter = 0; 
setId = setInterval("generateGravity()", 20); 
return true; 
} 
function generateGravity { 
if ((parseInt(bouncingBall.top)+iter < winH) && down) { 
bouncingBall.top = parseInt(bouncingBall.top) + iter; 
iter++; 
return; 
} 
else { 
if ((parseInt(bouncingBall.top)< winH) && down) { 
bouncingBall.top = winH + 5; 
return; 
} 
down = false; 
up = true; 
if (iter < 0 && parseint(bouncingBall.top) > winH) { 
clearInterval(setId); 
bouncingBall.visibility = "hidden"; 
stillBall.visibility="visible"; 
setId = 0; 
} 
if (parseInt(bouncingBall.top) > 0 && up && iter >= 0) { 
bouncingBall.top = parseint(bouncingBall.top) - iter; 
iter--; 
if (iter%3 == 0) iter--; 
return; 
} 
down = true; 
up = false; 
} 
} 
// End --> 
</script> 

<p><center> 
</center><p> 
</BODY> 
</HTML> 

答えて

0

あなたのブラウザはおそらく使用されていないのJavaScriptの古いバージョンで作業している。

私は自分のマシンにコピーされ、コンソールに2つのエラーが発生しました。最初のエラーのために

Uncaught SyntaxError: Unexpected token { 

file:///home/tkrg/lemon.png Failed to load resource: net::ERR_FILE_NOT_FOUND 

、()は無かったようです関数用に書かれたものです。それは

function generateGravity { 

が、私はあなたがレモンの絵を持っていると仮定しても安全だと思います、2番目のエラーのために

function generateGravity() { 

を言うべきであると述べました。

動作しませんでした他の二つのものがありました:

parseint() 

は今

parseInt() 

とこのです:

getElementId() 

は今

getElementById() 
ですが、

フルコード

<SCRIPT> 

function BrowserCheck() { 
var b = navigator.appName; 
if (b == "Netscape") this.b = "NS"; 
else if (b == "Microsoft Internet Explorer") this.b = "IE"; 
else this.b = b; 
this.v = parseInt(navigator.appVersion); 
this.NS = (this.b == "NS" && this.v>=4); 
this.NS4 = (this.b == "NS" && this.v == 4); 
this.NS5 = (this.b == "NS" && this.v == 5); 
this.IE = (this.b == "IE" && this.v>=4); 
this.IE4 = (navigator.userAgent.indexOf('MSIE 4')>0); 
this.IE5 = (navigator.userAgent.indexOf('MSIE 5')>0); 
if (this.IE5 || this.NS5) this.VER5 = true; 
if (this.IE4 || this.NS4) this.VER4 = true; 
this.OLD = (! this.VER5 && ! this.VER4) ? true : false; 
this.min = (this.NS||this.IE); 
} 
is = new BrowserCheck(); 
</script> 
</HEAD> 


<BODY> 

<center> 
Click on the screen to drop lemon<br> 
<div id="staticBall" style="position:relative;visibility:visible"> 
<img src="lemon.png" height=30 width=30 alt="Static lemon"> 
</div> 
</center> 
<div id="ball" style="visibility:hidden; position:absolute; left:100; top:10; height:34; width:34"> 
<img src="lemon.png" height=30 width=30 alt="Bouncing lemon"> 
</div> 

<script> 
iter = 0; 
setId = 0; 
down = true; 
up = false; 
bouncingBall = (is.VER5) ? document.getElementById("ball").style 
: (is.NS) ? document.layers["ball"] 
: document.all["ball"].style; 
stillBall = (is.VER5) ? document.getElementById("staticBall").style 
: (is.NS) ? document.layers["staticBall"] :   document.all["staticBall"].style; 
winH = (is.NS) ? window.innerHeight - 55 : document.body.offsetHeight - 55; 
document.onmouseup = buttonUp; 
if (is.NS4) 
document.captureEvents(Event.MOUSEUP); 
function buttonUp(e) { 
if (((is.NS) ? e.which : event.button) != 1) return true; 
if (setId != 0) clearInterval(setId); 
bouncingBall.visibility="visible"; 
stillBall.visibility="hidden"; 
bouncingBall.left = (is.NS) ? e.pageX - 15 : event.offsetX - 15; 
bouncingBall.top = (is.NS) ? e.pageY - 15 : event.offsetY - 15; 
iter = 0; 
setId = setInterval("generateGravity()", 20); 
return true; 
} 
function generateGravity() { 
if ((parseInt(bouncingBall.top)+iter < winH) && down) { 
bouncingBall.top = parseInt(bouncingBall.top) + iter; 
iter++; 
return; 
} 
else { 
if ((parseInt(bouncingBall.top)< winH) && down) { 
bouncingBall.top = winH + 5; 
return; 
} 
down = false; 
up = true; 
if (iter < 0 && parseInt(bouncingBall.top) > winH) { 
clearInterval(setId); 
bouncingBall.visibility = "hidden"; 
stillBall.visibility="visible"; 
setId = 0; 
} 
if (parseInt(bouncingBall.top) > 0 && up && iter >= 0) { 
bouncingBall.top = parseInt(bouncingBall.top) - iter; 
iter--; 
if (iter%3 == 0) iter--; 
return; 
} 
down = true; 
up = false; 
} 
} 
</script> 

<p><center> 
</center><p> 
</BODY> 
</HTML> 
関連する問題

 関連する問題