请大家帮我看看这段JS,有个简单的地方还不是很明白。

tmacwow 2005-09-05 11:24:22
JS如下:
function CheckUserInfo(UserName,PassWord)
{
var e = document.getElementById(UserName);
e.value = e.value.Trim();
if(e.value == "")
{
alert("请输入用户名");
event.cancelBubble=true;
event.returnValue=false;
e.focus();
return false;
}
e = document.getElementById(PassWord);
if(e.value == "")
{
alert("请输入用户密码");
event.cancelBubble=true;
event.returnValue=false;
e.focus();
return false;
}
}
这是个用来验证的脚本,当输入为空时弹出对话框,
其中event.cancelBubble=true;和event.returnValue=false;我不太明白,
在网上搜了一下,说是“设置或检索当前事件是否将事件句柄起泡 ”,和“设置或检索从事件中返回的值 ”,但我不知道放在这里具体来说有什么作用呢?

还请高手不吝赐教,最好是能说的通俗一点,呵呵:)
...全文
92 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
stpangpang 2005-09-07
  • 打赏
  • 举报
回复
cancelBubble Property Internet Development Index
--------------------------------------------------------------------------------
Sets or retrieves whether the current event should bubble up the hierarchy of event handlers.

不用它也可以
lovebanyi 2005-09-06
  • 打赏
  • 举报
回复
bCancel Boolean that specifies or receives one of the following values.false Default. Bubbling is enabled, allowing the next event handler in the hierarchy to receive the event.
true Bubbling is disabled for this event, preventing the next event handler in the hierarchy from receiving the event.
tmacwow 2005-09-06
  • 打赏
  • 举报
回复
这么说这个cancelbubble没用了?
lovebanyi 2005-09-06
  • 打赏
  • 举报
回复
event.cancelBubble=true;
event.returnValue=false;

这两个我从来没有用过啊. 不需要也行吧
jimu8130 2005-09-06
  • 打赏
  • 举报
回复
平常也没看到有人这样用
tmacwow 2005-09-06
  • 打赏
  • 举报
回复
我也觉得不用就应该可以,不过不知道写了有什么用
fly_miss 2005-09-05
  • 打赏
  • 举报
回复
再网页客户端的事件是从控件向form传递的。
event.cancelBubble=true,就是取消事件的传递

62,247

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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