为什么我不能在事件处理程序中使用window.event? [英] Why can't I use window.event in my event handler?

查看:120
本文介绍了为什么我不能在事件处理程序中使用window.event?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我知道我做的事情基本上是错的,但无法理解。我知道IE和FireFox以不同的方式处理事件。

i know that i'm doing something basically wrong but can't figure it out. I know that IE and FireFox handle events differently.

我为页面元素声明了一个onblur处理程序。

I declared an onblur handler for a page element.

JavaScript处理程序正在处理适当的时候。该事件应用于组合框元素。

The JavaScript handler is being alled at the appropriate time. The event is applied to a combobox element.

当我在调试模式下运行代码并且它到达这些行...

When I run the code in debug mode and it gets to these lines...

// ComboBox Blur Handler ===== ================================================== =======================

// ComboBox Blur Handler ==============================================================================

功能  myBlurHandler(){

Function myBlurHandler(){

var sender = window.event.srcElement;

}

我被告知对象

是必需的。

如果我没有,我很抱歉如果需要,可以正确使用CODE标签。我还注意到intellisense无法识别窗口的事件属性。有人可以告诉我可能出现的问题吗?

推荐答案

对于没有提供更详尽的情况,我深表歉意。我试图通过JavaScript将onblur事件处理程序添加到第三方控件组合框。在查看生成的HTML时,我发现所说的组合框实现为包含Input元素和ListBox的表。

I apologize for not supplying a more complete explanation of the situation. I was attempting via JavaScript to add an onblur event handler to a 3rd party control Combo Box. When looking at the generated HTML I discovered that the said Combo Box was being implemented as a Table containing an Input element and a ListBox.

因此我试图处理一个onblur事件表元素。从我读到的不是任何浏览器支持的东西。

Thus I was trying to handle the onblur event of a Table element. From what I read that is not something that is supported by any browsers.

我有点困惑的是我创建的事件处理程序确实正在触发。但是,window.event对象的内容为null。

I was a bit confused by the fact that the event handler that I created was indeed firing. However, the contents of the window.event object was null.

现在我想知道是否有任何其他方法来解决明显触发和处理的事件。

Now I am wondering if there is any other way to address the event that clearly is firing and being handled.

具体来说,我希望能够解决触发事件的表元素。 JavaScript似乎认识到通过服务器代码中实现的ID直接解决ComboBox,即ComboBox1。

Specifically I would like to be able to address the table element that fired the event. JavaScript seems to recognize directly addressing the ComboBox by the ID implemented in Server code, i.e. ComboBox1.

我想我可以尝试但是我将无法使用相同的处理程序页面上的6个组合框。

I suppose I could try that but then I would not be able to use the same handler for the 6 Combo Boxes on the page.

感谢任何打扰阅读此内容的人。

Thanks to anyone who bothered to read this.


这篇关于为什么我不能在事件处理程序中使用window.event?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆