-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoverridingOnLoad.js
More file actions
23 lines (21 loc) · 812 Bytes
/
overridingOnLoad.js
File metadata and controls
23 lines (21 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// set focus after page loads while respecting any framework code
if( window.attachEvent ) {
window.attachEvent( 'onload', customOnLoad );
} else {
if( window.onload ) {
var curronload = window.onload;
var newonload = function() {
curronload();
customOnLoad();
};
window.onload = newonload;
} else {
window.onload = customOnLoad;
}
}
function customOnLoad() {
// EXAMPLE: start page focusing on the cancel button
var cancelButton = document.getElementById( "cancelButton" );
console.log( "cancelButton", cancelButton );
cancelButton.focus();
}