By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,254 Members | 2,418 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,254 IT Pros & Developers. It's quick & easy.

How to check if a property is writable?

P: n/a
mav
To stop the keyboard event for the F4-key from propagating in IE I need
to set event.keyCode to 0. But setting keyCode to 0 in Mozilla/Firefox
will throw an exception since it is a read-only property.

So, how do I check if event.keyCode is writable?

(I could do some check to see if the script is run in IE or add a
try/catch for Mozilla, but I would like to know the 'correct' method)

Thanks, MAV

Jan 17 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
mav said the following on 1/17/2006 7:18 AM:
To stop the keyboard event for the F4-key from propagating in IE I need
to set event.keyCode to 0. But setting keyCode to 0 in Mozilla/Firefox
will throw an exception since it is a read-only property. So, how do I check if event.keyCode is writable?


You don't. You cancel propogation and return false from the onkey* event
handler.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 17 '06 #2

P: n/a
mav
I completely agree, but this doesn't work for certain keys (e.g. F4).
AFAIK the only way to cancel the F4 key in IE is to set keyCode to 0.

Jan 17 '06 #3

P: n/a
mav said the following on 1/17/2006 8:01 AM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
I completely agree, but this doesn't work for certain keys (e.g. F4).
AFAIK the only way to cancel the F4 key in IE is to set keyCode to 0.


Why are you trying to redefine my keyboard?
F4 in IE shows me my Address Bar drop-down.
F4 in Mozilla does nothing for me.
So I don't see where trying to cancel F4 does any good unless it does
something different that I am not seeing (I opened both and hit F4 to
see what the key does).

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 17 '06 #4

P: n/a
mav

Randy Webb schreef:
Why are you trying to redefine my keyboard?
F4 in IE shows me my Address Bar drop-down.
F4 in Mozilla does nothing for me.
So I don't see where trying to cancel F4 does any good unless it does
something different that I am not seeing (I opened both and hit F4 to
see what the key does).


Our customer specifically requested the use of the F4 key to submit
pages (to make the transition from the legacy application easier).
So I need to catch the F4-key in the (on)keydown, submit the form and
cancel the default action.

Jan 17 '06 #5

P: n/a
mav wrote:
Randy Webb schreef:

Why are you trying to redefine my keyboard?
F4 in IE shows me my Address Bar drop-down.
F4 in Mozilla does nothing for me.
So I don't see where trying to cancel F4 does any good unless it does
something different that I am not seeing (I opened both and hit F4 to
see what the key does).

Our customer specifically requested the use of the F4 key to submit
pages (to make the transition from the legacy application easier).
So I need to catch the F4-key in the (on)keydown, submit the form and
cancel the default action.


Since there Mozilla doesn't appear to have default action defined for
the F4 key, there's nothing to cancel. ;-)
There's a discussion here that may help:

<URL:
http://groups.google.com/group/comp....2df56c39040975

--
Rob
Jan 17 '06 #6

P: n/a
mav said the following on 1/17/2006 8:52 AM:
Randy Webb schreef:

Why are you trying to redefine my keyboard?
F4 in IE shows me my Address Bar drop-down.
F4 in Mozilla does nothing for me.
So I don't see where trying to cancel F4 does any good unless it does
something different that I am not seeing (I opened both and hit F4 to
see what the key does).

Our customer specifically requested the use of the F4 key to submit
pages (to make the transition from the legacy application easier).


Maybe you need to educate your customer on the futility of it then.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 17 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.