This is probably something simple I'm overlooking but my google-fu isn't turning anything up that could explain the cause. Take the following snippet for example (Ignoring for now that embedded js is generally considered bad practice):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>
</title>
</head>
<body>
<form action="">
<div>
<input type="text" id="pattern" value="foobar">
<input type="button" value="Alert" OnClick="alert(pattern.value);">
</div>
</form>
</body>
</html>
The above will print the alert message 'foobar' in IE8 and Firefox 3 but Chrome will print 'undefined'. Changing pattern
to something else like pattern_
will print 'foobar' for all three browsers as expected.
Is pattern
a reserved word or a name used for one of the builtin js libraries? What's the reason for this not working under Chrome?