首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

js 怎么获取方法的返回值!

2012-04-26 
js 如何获取方法的返回值!!!!function Init(){alert(testA())}function testA(){//testB()能不能像C#那

js 如何获取方法的返回值!!!!
function Init(){
  alert(testA());
}

function testA(){
  //testB(); 能不能像C#那样获取
}

function testB(){
  return "hello";
}

[解决办法]

HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>onresize test</title></head><body onload='Init()'><script type="text/javascript">    function Init() {        alert(testA());            }    function testA() {        var a = testB();        return a;           }    function testB() {        return "hello";    }</script></body></html>
[解决办法]
<script type="text/javascript">
function Init(){
alert(testA());
}

function testA(){
return testB(); 
}

function testB(){
return "hello";

Init();
</script>
[解决办法]
function Init(){
alert(testA());
}

function testA(){
return testB(); 能不能像C#那样获取
}

function testB(){
return "hello";
}

调用Init()会弹出"hello";
[解决办法]
+1这样就可以获得返回值了呀。
探讨
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>

<title>onresize test</title>


</head>

<……

热点排行