javascript判断函数是否存在问题?

cac_wh 2004-06-19 02:33:39
在html页面中如下代码:
<input name=n1 type=text onBlue="lostfocus()" value="">

通过javascript能否判断元素n1的onBlue事件是否存在,如果能判断,如何判断?
我是想实现判断一个元素的onBlue事件是否存在,如果存在,调用它
谢谢!
...全文
778 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
LxcJie 2004-06-20
  • 打赏
  • 举报
回复
<BODY onLoad="test()">
<INPUT type="text" id="txt" onBlur="alert('hello')">
</BODY>
<SCRIPT language="javascript">
function test()
{
if(document.all.txt.onblur == null)
alert("no onblur");
else
alert("onblur");
}
</SCRIPT>
myy 2004-06-19
  • 打赏
  • 举报
回复
if(typeof(nl.onBlue)=="function")
{
//存在
}
else
{
//不存在
}
wanghr100 2004-06-19
  • 打赏
  • 举报
回复
<input name=n1 type=text onblur="try{lostfocus()}catch(e){;}" value="">
<script>
function lostfocus()
{
alert('0')
}
</script>
cac_wh 2004-06-19
  • 打赏
  • 举报
回复
我写错了,应该是onBlur函数,在onload事件中判断元素n1的onBlur函数是否存在,如果存在,就调用
cac_wh 2004-06-19
  • 打赏
  • 举报
回复
我知道,我想在页面onload事件中判断该元素的onblue的事件是否存在,如果存在,就调用它
keaizhong 2004-06-19
  • 打赏
  • 举报
回复
你这个就是错误的。
又没有onblue事件。
有个类似的是onblur=""
这个不用判断吧。
等你失去焦点的时候就会调用的。

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧