The following code suppresses the 'enter' key, when run in I.E. 5.5 or
later (Windows) but not when run in Safari (Mac)
<body onkeypress="javascript:keysuppress(event)" >
function keysuppress(e)
{
if (e.type=="keypress" && e.keyCode=="13")
{
event.returnValue=false
}
}
What code can I use to suppress the 'enter' key when running an app in
Safari?
Thanks. 3 1984
Marcia Gulesian <mg@theworld.com> writes: The following code suppresses the 'enter' key, when run in I.E. 5.5 or later (Windows) but not when run in Safari (Mac)
.... or pretty much any non-IE browser.
<body onkeypress="javascript:keysuppress(event)" >
Just:
<body onkeypress="keysuppress(event)">
You almost never need to write "javascript:" in your pages.
A better way would be:
<body onkeypress="return keysuppress(event)">
Returning false from the handler is the most consistent way of
stopping an event.
function keysuppress(e) { if (e.type=="keypress" && e.keyCode=="13")
No need to test the event type when you are only called from an
"onkeypress" intrinsic event handler - it will be a key press.
The keyCode is a number, so it would be prettier to compare with the
number 13 instead of the string "13". And marginally more efficient,
if it mattered (it doesn't).
{ event.returnValue=false
Here you use "event" instead of the variable "e". IE makes the event
available as the global variable "event", but not all other browsers
do. The "returnValue" property of the event is also an IE invention.
To be consistent with the W3C DOM, you should call the method
"preventDefault" on the event (but obviously, IE doesn't have one).
For maximal consistency, you would write:
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
Or, with the addition of the "return" in the handler text above,
you could just return false:
---
function keysuppress(e) {
return (e.keyCode != 13);
}
---
What code can I use to suppress the 'enter' key when running an app in Safari?
I don't have access to Safari, but I'll be surpriced if this doesn't work.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Thank you Lasse.
Lasse Reichstein Nielsen wrote: Marcia Gulesian <mg@theworld.com> writes:
The following code suppresses the 'enter' key, when run in I.E. 5.5 or later (Windows) but not when run in Safari (Mac)
... or pretty much any non-IE browser.
<body onkeypress="javascript:keysuppress(event)" >
Just: <body onkeypress="keysuppress(event)"> You almost never need to write "javascript:" in your pages. A better way would be: <body onkeypress="return keysuppress(event)"> Returning false from the handler is the most consistent way of stopping an event.
function keysuppress(e) { if (e.type=="keypress" && e.keyCode=="13")
No need to test the event type when you are only called from an "onkeypress" intrinsic event handler - it will be a key press.
The keyCode is a number, so it would be prettier to compare with the number 13 instead of the string "13". And marginally more efficient, if it mattered (it doesn't).
{ event.returnValue=false
Here you use "event" instead of the variable "e". IE makes the event available as the global variable "event", but not all other browsers do. The "returnValue" property of the event is also an IE invention.
To be consistent with the W3C DOM, you should call the method "preventDefault" on the event (but obviously, IE doesn't have one).
For maximal consistency, you would write:
if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; }
Or, with the addition of the "return" in the handler text above, you could just return false: --- function keysuppress(e) { return (e.keyCode != 13); } ---
What code can I use to suppress the 'enter' key when running an app in Safari?
I don't have access to Safari, but I'll be surpriced if this doesn't work. /L -- Lasse Reichstein Nielsen - lr*@hotpop.com DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.'
Lasse Reichstein Nielsen wrote: Marcia Gulesian <mg@theworld.com> writes: What code can I use to suppress the 'enter' key when running an app in Safari?
I don't have access to Safari, but I'll be surpriced if this doesn't work.
^^^^^^^^^
Sorry for the public "spelling flame" but since you do not seem to read
your e-mails: It is _surprised_ and _surprise_. Seems to be a common
mistake among European students that to not have English as native
language, especially in Scandinavian countries (from what Google tells me).
HTH
\V/ PointedEars This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sanj |
last post by:
Hi all,
My site is located at:
http://www.eastdayspa.com/index.html
I have use these main styles
/* main styles */
|
by: Foreman |
last post by:
Using ASPFileUpload
(http://support.microsoft.com/default.aspx?scid=kb;en-us;299692) and works
for IE6 and FireFox but not Safari.
Thanks in advance for your assistance.
|
by: Nitronic |
last post by:
I got this javascript code below and each time i got to a safari browser
it thinks its netscpe any ideas. But i threw in Safari code but it doesn't
work.
var browserName=navigator.appName;
//...
|
by: laredotornado |
last post by:
Hi,
Is it possible to fool Javascript running on a Mac Safari web
browser into believing it is a PC IE browser? We have the following JS
code that is detecting both Mac and Safari. Sadly, we do...
|
by: metoikos |
last post by:
I've scoured the web (clumsily, I'm sure) for information on the
difficulties I am having, checked my markup in validators, and had a
friend with more CSS clue look over it, but I haven't had any...
|
by: Simon Wigzell |
last post by:
document...focus() will scroll the form to move the
specified text field into view on everything I have tried it with except
Safari on the MAC. The form doesn't move. Any work around? Thanks.
|
by: Will Hartung |
last post by:
Hi all,
I seem to be having an issue color matching between the cut up graphic
pieces and the block fill background colors on a Mac iBook running Safari.
Simply put, while the color are...
|
by: Edward |
last post by:
Hi All,
I am having huge problems with a very simple dotnet framework web page
(www.gbab.net/ztest3.aspx) , it does NOT render correctly under Apple's
Safari. The DIV's do not align amd float as...
|
by: David Stone |
last post by:
Run into something recently that has left me a little puzzled.
According to the examples in section 13.6.1 of html 4.01...
<http://www.w3.org/TR/html401/struct/objects.html#h-13.6.1.1>
I...
|
by: Brad |
last post by:
I have an aspx page that is sending pdf files to client browsers: it uses a filestream to read the pdf file and
response.binarywrite to send content to the browser. This has worked great for years...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |