-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFocusExample01.htm
More file actions
executable file
·27 lines (25 loc) · 963 Bytes
/
Copy pathFocusExample01.htm
File metadata and controls
executable file
·27 lines (25 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!DOCTYPE html>
<html>
<head>
<title>Focus Example</title>
<script type="text/javascript" src="EventUtil.js"></script>
</head>
<body>
<p>The textbox will receive focus as soon as the page loads. You can then start typing.</p>
<form method="post" action="javascript:alert('Form submitted!')" id="myForm">
<div>
<label for="comments">Any comments?</label><br>
<textarea rows="10" cols="50" id="comments" name="comments" autofocus></textarea>
</div>
<input type="submit" value="Submit Form" id="submit-btn">
</form>
<script type="text/javascript">
EventUtil.addHandler(window, "load", function(event){
var element = document.forms[0].elements[0];
if (element.autofocus !== true){
element.focus(); console.log("JS focus");
}
});
</script>
</body>
</html>