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 1982
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 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |