[急]手动触发事件如何获取执行的返回值?htmlheadscriptfunction test1(a){document.getElementById(
[急]手动触发事件如何获取执行的返回值?
<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>
[解决办法]
- HTML code
<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>
[解决办法]
this?
- HTML code
<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> 