Html的一些小东西

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">

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

 

posted @ 2008-08-21 14:51  Aldebaran's Home  阅读(290)  评论(0编辑  收藏  举报