请问,用JAVASCRIPT,为什么此语句没响应 window.captureEvents(Event.CLICK),请帮忙!!!

loveyu 2001-07-17 02:19:03
请问,用JAVASCRIPT,为什么此语句没响应 window.captureEvents(Event.CLICK),请帮忙!!!
我用的浏览器是IE5.O(WIN2000)
...全文
178 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
mjm_d 2001-07-20
  • 打赏
  • 举报
回复



直接一点
IE 不支持event
孟子E章 2001-07-17
  • 打赏
  • 举报
回复
NetScape需要那个方法,IE里不需要:例子:

<script>
if (navigator.appName == "Netscape") {
document.captureEvents(Event.CLICK);
}

document.onclick = printEvent;

function printEvent(e) {
if (navigator.appName == "Microsoft Internet Explorer"){
mX = event.clientX;
mY = event.clientY;
}
else {
mX = e.pageX;
mY = e.pageY;
}
alert("Click at x = " + mX + " and y = " + mY);
}

</script>
孟子E章 2001-07-17
  • 打赏
  • 举报
回复
Capturing Events


Internet Explorer 4.0x doesn't provide an explicit function for capturing events at the window or document level. An event is captured by an object when the event reaches it, provided that the object has an event handler that processes the event. If the object doesn't have such an event handler, the event is released.

You may recall that Navigator 4.0x features two methods that capture and release events:

captureEvents()
releaseEvents()

In Internet Explorer 4.0x you simply need to specify an event processing function to capture an event. The following script segment captures all click events that occur on the document:


<SCRIPT LANGUAGE="JavaScript">
<!--

document.onclick = functionName;

// -->
</SCRIPT>

For example, if you put the following script in your HTML document, an alert dialog box pops up when you click anywhere on the document:


<SCRIPT LANGUAGE="JavaScript">
<!--

function processClicks() {
alert("Thank you for clicking the mouse button.");
}

document.onclick = processClicks;

// -->
</SCRIPT>
孟子E章 2001-07-17
  • 打赏
  • 举报
回复
Netscape Navigator requires the captureEvents() method to capture events outside of its intended target (in the window, layer, or document object). For example, the following code segment captures all mouseup events in the document:

document.captureEvents(Event.MOUSEUP);
document.onmouseup = functionName;
Since Internet Explorer's event model is based on event bubbling, an event is first directed to its intended target (the element that initiated the event). Therefore, the captureEvents() method is not featured in Internet Explorer. It simply isn't required. As a scripter, you must make sure it is not executed under Internet Explorer.

87,904

社区成员

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

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