亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

javascript中return true的作用?

javascript中return true的作用?

夜盡天明ht 2016-05-21 10:15:04
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>無標題文檔</title></head><script>function addLoadEvent(func){ var oldonload=window.onload; if (typeof window.onload !='function'){ window.onload=func; } else{ window.onload=function(){ oldonload(); func(); } } }function positionMessage(){ if(!document.getElementById) return false; if(!document.getElementById) return false; var elem=document.getElementById("message"); elem.style.position="absolute"; elem.style.left="50px"; elem.style.top="100px"; }function moveMessage(){ if(!document.getElementById) return false; if(!document.getElementById("message"))return false; var elem=document.getElementById("message"); var xpos=parseInt(elem.style.left); var ypos=parseInt(elem.style.top); if(xpos==200&&ypos==100){ return true; } if(xpos<200){ xpos++; } if(xpos>200){ xpos--; } if(ypos<100){ ypos++; } if(ypos>100){ ypos--; } elem.style.left=xpos+"px"; elem.style.top=ypos+"px"; movement=setTimeout("moveMessage()",10); }addLoadEvent(positionMessage);addLoadEvent(moveMessage);</script><body><p id="message">whee</p></body></html>這個里面用return?true;是不是實現了一個循環,這個地方?if(xpos<200){ xpos++; } if(xpos>200){ xpos--; } if(ypos<100){ ypos++; } if(ypos>100){ ypos--; } elem.style.left=xpos+"px"; elem.style.top=ypos+"px"; movement=setTimeout("moveMessage()",10);是不是都在循環,怎么有循環的作用,求告訴return的作用,謝謝
查看完整描述

1 回答

?
夜盡天明ht

TA貢獻3條經驗 獲得超2個贊

大致明白了一點,就是不知道這個return true的作用范圍是怎么規定的?

查看完整回答
反對 回復 2016-05-21
  • 1 回答
  • 0 關注
  • 2043 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號