Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / May 2007



Tip: Looking for answers? Try searching our database.

Broken Event Model in IE

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
getsanjay.sharma@gmail.com - 30 May 2007 19:00 GMT
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.
Geoffrey Summerhayes - 30 May 2007 21:46 GMT
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?
[quoted text clipped - 12 lines]
>                 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
getsanjay.sharma@gmail.com - 31 May 2007 02:18 GMT
> javaScript camelCase
>
[quoted text clipped - 6 lines]
> ---
> 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.