Event object in Safari

T

Tim Slattery

We have a page that uses the onkeyup action to check what's put into a
form field as it's being typed. The handler for this action uses the
event action. To handle IE and Netscape/Firefox, it uses this code to
get the event object:

if (document.all)
{
eventObject="window.event";
}
else
{
eventObject="event"
}

The string is later used as an argument to eval (I know there are
better ways).

The function doesn't work in Safari. Does the event object in Safari
live somewhere other than where this code looks for it?

We're handicapped here because we're an IE shop. We're allowed
(barely) to install Netscape, which gives us access to the Gecko
engine, but no Mac, no Safari.
 
T

Thomas 'PointedEars' Lahn

Tim said:
We have a page that uses the onkeyup action to check what's put into a
form field as it's being typed. The handler for this action uses the
event action. To handle IE and Netscape/Firefox,

You should expand your knowledge about available Web user agents ASAP.
it uses this code to get the event object:

if (document.all) { eventObject="window.event"; } else {
eventObject="event" }

The string is later used as an argument to eval (I know there are better
ways).

A man comes to the doctor and says: "..."
The function doesn't work in Safari.

Since you don't show the code that actually creates the reference, that
statement does not help in the analysis of your possible mistake.

http://jibbering.com/faq/faq_notes/clj_posts.html#ps1DontWork
Does the event object in Safari live somewhere other than where this code
looks for it?

At least in Safari 3 Beta on Windows[1] it lives exactly where it is
supposed to be, and in compliance with W3C DOM Level 2 Events a reference to
it is available as the first and only argument of an event listener. As it
is also the case with Gecko and Opera, BTW.

It does not even matter if you assign the event listener proprietarily with

inputRef.onkeyup = function(e)
{
window.alert(e);
};

or standards-compliant with

inputRef.addEventListener(
"keyup",
function(e)
{
window.alert(e);
},
false);

I could test with Safari 2.0.x on Mac OS X tomorrow.

[1] Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE) AppleWebKit/523.15
(KHTML, like Gecko) Version/3.0 Safari/523.15
We're handicapped here because we're an IE shop.

I beg your pardon?
We're allowed (barely) to install Netscape, which gives us access to the
Gecko engine, but no Mac, no Safari.

OMG. You should definitely not develop for the Web then.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Randy said:
Tim Slattery said the following on 1/8/2008 2:24 PM:

If you want access to the Gecko engine, then install Firefox instead of
Netscape. Netscape is built on Firefox, not the other way around.

Netscape 6.x, 7.x, and Firefox are fully Gecko-based; Netscape 8+ is only
partially Gecko-based as it can also use MSHTML's Trident layout engine.
Netscape is not and has never been based on Firefox.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top