If you create a form in HTML like so:
<!DOCTYPE html>
<html><head>
<script>
function submit() {
console.log("window.submit");
}
</script>
</head>
<body>
<form name="form">
<input type="button" value="button" onclick="submit()" />
</form>
</body>
</html>
When the input
tag is parsed (in chrome at least), the corresponding DOM element will apparently be created with the form as the scope, so that the function bound to the onclick handler will be form.submit()
rather than window.submit()
. Is this standard behavior or browser dependent? Is there any documentation that covers this?