Event

cancelBubble
设置或获取当前事件是否要在事件句柄中向上冒泡。

Sets or retrieves whether the current event should bubble up the hierarchy of event handlers.

<SCRIPT LANGUAGE="JScript">

function checkCancel() {

if (window.event.shiftKey) //只要你按着shift键,就不会再触发BODY 的onclick了

window.event.cancelBubble = true;

}

function showSrc() {

if (window.event.srcElement.tagName == "IMG")

alert(window.event.srcElement.src);

}

</SCRIPT>

<BODY onclick="showSrc()">

<IMG onclick="checkCancel()" src="sample.gif">

用途:阻止父控件或以上级控件触发相应事件

 

相关文章:

  • 2021-05-18
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-02-22
  • 2022-12-23
  • 2021-07-27
  • 2022-02-10
猜你喜欢
  • 2021-08-04
  • 2021-12-14
  • 2021-12-10
  • 2021-11-28
  • 2021-12-20
  • 2022-12-23
  • 2022-01-16
相关资源
相似解决方案