日期:2014-05-16  浏览次数:20468 次

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>

<……