AMysticWeb said:
Hi Steve,
http://frontpageforms.com/disable_enter.htm
Mike Smith,
http://FrontPageForms.com
FrontPage Form Tutorials
& Form Script Examples
Mike,
I made the first suggestion and you followed it up with a mroe general
function
function checkCR(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ?
evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
document.onkeypress = checkCR;
Here is something which has interested me for some time
Please explain my ignorance
Point 1. An event is set equal to a function
I take this to mean:
When the event document.onkeypress occurs, execute the function
checkCR(evt)
Point 2. A function checkCR is defined with a parameter evt that is never
passed to it
I don't undertand this.
How can the function check for the existence of evt as a passed parameter
when it is never passed ?
The first line seems to mean:
If the parameter evt exists set local variable evt equal to the value of the
parameter evt
Else
If the global variable event exists set local variable evt equal to the
value of the global variable event
Else
Set local variable evt equal to null
The second line seems to mean:
If evt.target exists set local variable node equal to evt.target
Else
If evt.srcElement exists set local variable node equal to evt.srcElement
Else
Set local variable node equal to null
I assume therefore that these are known (or may be known depending on the
browser)
evt OR event
evt.target OR event.target OR evt.srcElement OR event.srcElement
evt.keyCode OR event.keyCode
evt.target.node.type OR event.target.node.type OR
evt.targetsrcElement.node.type OR event.target.srcElement.node.type
Can you state what these entities are
I assume:
evt or event is:
some event such as keypress. What are the other possibilities?
evt.target OR event.target OR evt.srcElement OR event.srcElement is:
the element where the event takes place, e.g. an <input> tag which has a
kepypress event
evt.keyCode OR event.keyCode is:
the keyCode associated with the event (e.g. a keypress)
evt.target.node.type OR event.target.node.type OR
evt.targetsrcElement.node.type OR event.target.srcElement.node.type is:
the type of the element where the event takes place, e.g. "text" or
"textarea"
However, I note that the code does not contain any element with type="text"
Is node.type="text" a generic type which includes <input> and <textarea> ?
Any others?