You are here: irt.org | FAQ | JavaScript | Form | 11 | Q1777 [ previous next ]
Keeps window on top (in focus) but allows text box to have focus when user needs to enter text. Just create page with code below and then open it as a pop up window and it will always have focus except when trying to edit the text box, and after the text box loses focus the window regains it!!
<HTML>
<HEAD>
<SCRIPT Language="JavaScript">
var isOnBlur = true;
function checkOnBlur() {
if (isOnBlur == true) {
self.focus();
}
}
function setisOnBlur(bolisOnBlur, object) {
if (bolisOnBlur == 1) {
isOnBlur = false;
object.focus();
} else {
isOnBlur = true;
checkOnBlur();
}
}
</SCRIPT>
</HEAD>
<BODY onBlur="checkOnBlur()">
<FORM>
<INPUT type="text" name=aTextBox onMouseOver="setisOnBlur(1, this)" onFocus="setisOnBlur(1, this)" onBlur="setisOnBlur(2, this)" >
</FORM>
</BODY>
</HTML>Submitted by Scott Millett