473,396 Members | 1,927 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.

Broken Event Model in IE

Any reason why the following snippet works as expected in Firefox but
fails miserably in IE?

<html>
<head>
<script>
var ENTER_KEY = 13;

function myKeyPressed(e)
{
if(!e)
var e = window.event;
if(e.keycode)
code = e.keycode;
else if(e.which)
code = e.which;

if(code == ENTER_KEY)
{
alert('You pressed the ENTER key');
return true;
//call the function which performs calculation
}
else
{
alert('Press the correct key');
return false;
}
}
</script>
</head>
<body>
<form>
<label>Box</label><input type="text" name="txt" id="txt"
onkeypress="javascript:return myKeyPressed(event)" />
</form>
</body>
</html>

Some good links referring to the events in JS would be appreciated.

Thanks and regards,
S T S.

May 30 '07 #1
2 1128
On May 30, 2:00 pm, getsanjay.sha...@gmail.com wrote:
Any reason why the following snippet works as expected in Firefox but
fails miserably in IE?

<html>
<head>
<script>
var ENTER_KEY = 13;

function myKeyPressed(e)
{
if(!e)
var e = window.event;
if(e.keycode)
code = e.keycode;
else if(e.which)
code = e.which;
javaScript camelCase

e.keyCode
Some good links referring to the events in JS would be appreciated.
Don't really have any. I usually bounce between mozilla's
developer ref, W3, and MSDN.

Strangely, I find the MS ref. the easiest to find things in.

---
Geoff

May 30 '07 #2
On May 31, 1:46 am, Geoffrey Summerhayes <sumr...@gmail.comwrote:
javaScript camelCase

e.keyCode
Some good links referring to the events in JS would be appreciated.

Don't really have any. I usually bounce between mozilla's
developer ref, W3, and MSDN.
---
Geoff
Thanks a lot Geoff. I thought that since onclick was the same as
onClick, the same can be applied anywhere, but I guess it was a wrong
thought. Maybe a search for 'Mozilla Javascript reference', 'W3C
Javascript reference' or 'MSDN javascript reference' should turn out
to be fruitful.

Thanks and Regards,
S T S.

May 31 '07 #3

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

Similar topics

4
by: Margaret MacDonald | last post by:
I'm trying to write a filter that will ignore text of the form '\_foo\_' while filtering text of the form '_foo_'. In other words, a backslash is meant to protect against the operation of this...
42
by: cody | last post by:
public DateTime Value { get { try { return new DateTime(int.Parse(tbYear.Text), int.Parse(tbMonth.Text), int.Parse(tbDay.Text)); } catch (FormatException)
205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
2
by: kj | last post by:
How does one trigger an event programmatically? I'm interested in how to do this in both the "Level 0" event model as well as in the DOM Level 2 event model. Thanks! kj -- NOTE: In my...
1
by: Wavemaker | last post by:
I was wondering if there is a way to change the value of a control without triggering an event. The ComboBox control, for example, will trigger the SelectedIndexChanged event when its SelectedIndex...
6
by: Steve B. | last post by:
Is it good programming practice to call an event within an event? I'm I creating recursion somehow somewhere? Does an event (e.g. send, e) ever end? I'm sorry, I'm not sure I know what I mean,...
8
by: Paul | last post by:
Hi, In a class i built, i fire an event when a field changes. In a webform that has an instance of the class, the event (from the class) is fired and the code is executed. However, my webpage...
3
by: geskerrett | last post by:
We have been asked to develop and application for a client that is a 'notification" system. We would like to use python, but are struggling to find the right starting point. Any suggestions, tips...
14
by: Snor | last post by:
I'm attempting to create a lobby & game server for a multiplayer game, and have hit a problem early on with the server design. I am stuck between using a threaded server, and using an event driven...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.