Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1777 Is there a way to have a window self focus but still allow the user to enter data into a form?

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

©2018 Martin Webb