473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

strange event handling problem in IE

yb
Hi,

In IE I usually check for event objects in event handlers with
something like:

handler = function( e ) {
if( !e ) var e = window.event;
....
}

I am also using IE 'attachEvent' to register the event handler.
However, IE (6) passes in an empty 'e' object, and not an undefined
value. Has anyone had this problem before. I've only noticed it
recently, and I'm wondering if the windows update changed something in
IE. I'm now forced to check for both e, and the relevant property,
e.g. e && e.target

My IE version is:

6.0.2900.2180.xpsp_sp2_gdr.050301-1519

Nov 23 '05 #1
9 2503

yb wrote:
Hi,

In IE I usually check for event objects in event handlers with
something like:

handler = function( e ) {
if( !e ) var e = window.event;
....
}
Not strange at all. IE has never passed an 'e' object to an event
handler. Other browsers, such as FireFox do. That is why you check to
ensure whether or not 'e' is defined, if it's not, used IE's
window.event to assign it to 'e'.
I am also using IE 'attachEvent' to register the event handler.
However, IE (6) passes in an empty 'e' object, and not an undefined
value. Has anyone had this problem before. I've only noticed it
recently, and I'm wondering if the windows update changed something in
IE. I'm now forced to check for both e, and the relevant property,
e.g. e && e.target

My IE version is:

6.0.2900.2180.xpsp_sp2_gdr.050301-1519


Nov 23 '05 #2
yb
My point is that IE *is* passing in the 'e' object.

I'm getting an e object passed in from IE, so the check

if( !e ) var e = window.event

does not assign window.event to e, and all event handling fails.
The e object passed in is empty with no properties but not undefined

Nov 23 '05 #3
yb wrote:
Hi,

In IE I usually check for event objects in event handlers with
something like:

handler = function( e ) {
if( !e ) var e = window.event;
....
}

I am also using IE 'attachEvent' to register the event handler.
However, IE (6) passes in an empty 'e' object, and not an undefined
value. ...

My IE version is:

6.0.2900.2180.xpsp_sp2_gdr.050301-1519


I have the same version as you, but IE does not pass an empty event
object for me.
Reinstall IE? Or maybe there is some other js code that interferes with
the event.
Nov 23 '05 #4
web.dev wrote:
yb wrote:
Hi,

In IE I usually check for event objects in event handlers with
something like:

handler = function( e ) {
if( !e ) var e = window.event;
....
}

Not strange at all. IE has never passed an 'e' object to an event
handler.


He uses attachEvent in which case IE6 does pass an event object.
Nov 23 '05 #5
yb
> He uses attachEvent in which case IE6 does pass an event object.

What information does this object include? I haven't found anything in
msdn docs about it.

Perhaps a bug? I haven't had time to test this further, but I'm pretty
sure this object was empty.

Nov 23 '05 #6
yb wrote:
He uses attachEvent in which case IE6 does pass an event object.


What information does this object include? I haven't found anything in
msdn docs about it.


Have you even looked for it? Documentation is linked as the first hit on
<http://search.microsoft.com/search/results.aspx?qu=event&View=msdn&st=b&c=4&s=1&swc=4 >
PointedEars
Nov 23 '05 #7
VK

Robert wrote:
yb wrote:
Hi,

In IE I usually check for event objects in event handlers with
something like:

handler = function( e ) {
if( !e ) var e = window.event;
....
}

I am also using IE 'attachEvent' to register the event handler.
However, IE (6) passes in an empty 'e' object, and not an undefined
value. ...

My IE version is:

6.0.2900.2180.xpsp_sp2_gdr.050301-1519


I have the same version as you, but IE does not pass an empty event
object for me.
Reinstall IE? Or maybe there is some other js code that interferes with
the event.


It is not an empty object. It's the same "event" object you can get as
global variable.

Traditionally IE provided event info via automatically created
contextually global variable "event" and Netscape > Gesko via
automatically assigned first argument in the event handler. But
starting IE 6.0.2800 (at least) it implements both ways, so you could
access event info in IE-way or Gesko-way. Very confusing and dangerous
actually, but I guess that the intentions were to facilitate developers
life :-) :-(

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">

<script type="text/javascript">

function init() {
document.getElementById('ie').attachEvent('onclick ',testIE);
}

function testIE(e) {
alert(e.srcElement.tagName);
alert(event.srcElement.tagName);
}

window.onload = init;
</script>

<style type="text/css">
body {background-color: #FFFFFF}
var {font: normal 10pt Verdana, Geneva, sans-serif;
color: #0000FF; text-decoration: underline;
cursor: hand; cursor:pointer}
</style>

</head>

<body>

<noscript>
<p><font color="#FF0000"><b>JavaScript disabled:-</b><br>
<i><u>italized links</u></i> will not work properly</font></p>
</noscript>

<p>
<var id="ie">Test</var>
</p>

</body>
</html>

Nov 23 '05 #8
yb
Sorry my wording was not accurate

yes, I have looked into the docs, what I meant is I could not find
information about IE passing in an object into the event handler.

On further testing, the object seems to be same as window.event, but I
can't find anything on msdn mentioning that it passing an event object
to the function as a paramter.

Nov 23 '05 #9
VK wrote:
Robert wrote:

I have the same version as you, but IE does not pass an empty event
object for me.
Reinstall IE? Or maybe there is some other js code that interferes with
the event.

It is not an empty object. It's the same "event" object you can get as
global variable.


Did you respond to me or the original poster?
Because I just said that I do not have an empty object.
Nov 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. ...
1
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. Here's the code: window.onload = init; function...
4
by: Eric | last post by:
How can I dynamically assign an event to an element? I have tried : (myelement is a text input) document.getElementById('myelement').onKeyUp = "myfnc(param1,param2,param3)"; ...
18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
3
by: Andrew Mayo | last post by:
(note: reason for posting here; browser helper object is written in C++; C++ developers tend to know the intricacies of message handling; this looks like a Windows messaging issue) Microsoft...
8
by: Mark | last post by:
Hi, I'm looking for some ideas on how to build a very simple Event processing framework in my C++ app. Here is a quick background ... I'm building a multithreaded app in C++ (on Linux) that...
3
by: Sebastian C. | last post by:
Hello everybody Since I upgraded my Office XP Professional to SP3 I got strange behaviour. Pieces of code which works for 3 years now are suddenly stop to work properly. I have Office XP...
3
by: Tony | last post by:
I have a WebApp with 3 text boxes and 1 button, as described below. Can someone please explain why the bad scenarios are occurring and better still if they can be prevented or worked-around?...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.