<html>
<head>
<script>
function test1(a)
{
    document.getElementById("ipt").fireEvent("onblur");  
    //这里怎么获取test2执行后的返回值?触发事件不一定要用fireEvent,其他方法能获取到相似效果也可以。
}function test2(obj)
{
    if (obj.value == 'test')
    {
        return false;   
    }
    return true;    
}
</script>
</head>
<body>
<input id="ipt" type="text" name="ipt" onblur="return test2(this)" />
<button onclick="test1()">test</button></body>
</html>

解决方案 »

  1.   

    楼主没必要再去取它的返回值,fireEvent只是去执行这个事件,你要实现什么功能在test2里面实现不就行了
      

  2.   

    <html>
    <head>
    <script>
    function test1(a) {
    alert(document.getElementById("ipt").onblur()); 
    }function test2(obj) {
    return obj.value != 'test';
    }
    </script>
    </head>
    <body>
    <input id="ipt" type="text" name="ipt" onblur="return test2(this)" />
    <button onclick="test1()">test </button>
    </body>
    </html>
      

  3.   

    this?<html> 
    <head> 
    <script> 
    function test1(a) 

        document.getElementById("ipt").fireEvent("onblur");  
        //这里怎么获取test2执行后的返回值?触发事件不一定要用fireEvent,其他方法能获取到相似效果也可以。 
        var e=document.getElementById("ipt").onblur();
        alert(e)
    } function test2(obj) 

        if (obj.value == 'test') 
        { 
            return false;  
        } 
        return true;    

    </script> 
    </head> 
    <body> 
    <input id="ipt" type="text" name="ipt" onblur="return test2(this)" /> 
    <button onclick="test1()">test </button> </body> 
    </html>