By loading the following simple javascript and html, I get the famous
Uncaught TypeError: Cannot read property 'value' of null
during the window.onload event if and only if I include the parenthesis on the event handler assignment as shown. If I change that line to read
window.onload = verifyAdd;
(no parenthesis) I do not get the error in my chrome/firefox debug panels. Why, exactly? Is there a functional difference?
Javascript:
window.onload = verifyAdd();
function verifyAdd() {
var first;
first = document.getElementById("txtFirstName").value;
}
HTML:
<html>
<head>
<script type="text/javascript" src="./frobozz.js"></script>
</head>
<body>
<input type=text id=txtFirstName name=txtFirstName size=30 onchange=verifyAdd() />
</body>
</html>