So I have a following line of Javascript on my page:
form.display.value = 'Error';
where display is an input of type text on my page:
<input type="text" id="calcDisplay" name="display" maxlength="25">
in Chrome this works just fine making the value of the input element to be "Error". But in IE 10 and Firefox the content of the input is the following:
function Error() { [native code]}
Can anyone explain what is going on here and why?
UPDATE: This is the actual function being called:
function compute(form) {
try {
form.display.value = eval(form.display.value);
} catch(e) {
form.display.value = 'Error';
}
}
And here is the video of it so you guys don't think that I'm crazy:
When the value
Error
is already in the input, this line:...is going to evaluate to the function
Error
you defined earlier. So this must be happening on a second call to yourcompute
function.Note that browsers are inconsistent with how
eval
works, which is why you see browser differences.