R
Robert Oschler
I have a textarea element that I have created an onblur() handler for.
In the onblur() handler, I check to make sure that they have saved the
contents of the edit box, before leaving it.
If they have not saved the contents, when they exit the edit box, I put up
an alert telling them to perform the save.
My handler (note: the editBox variable was properly assigned a reference to
the desired HTML textarea element earlier):
function onEditBoxBlur()
{
if (bNotSaved)
{
alert("Please save your new text.");
editBox.focus();
return false;
}
return true;
}
However, after they hit OK to the alert box, focus ends up in a textarea
element *below* the desired edit box (the one has the onEditBoxBlur() as
it's "onblur" handler).
If I remove the editBox.focus() statement, then focus returns to the web
page itself instead.
Why is this happening and how can I fix things so that focus returns to the
desired textarea control ("editBox")?
Thanks.
In the onblur() handler, I check to make sure that they have saved the
contents of the edit box, before leaving it.
If they have not saved the contents, when they exit the edit box, I put up
an alert telling them to perform the save.
My handler (note: the editBox variable was properly assigned a reference to
the desired HTML textarea element earlier):
function onEditBoxBlur()
{
if (bNotSaved)
{
alert("Please save your new text.");
editBox.focus();
return false;
}
return true;
}
However, after they hit OK to the alert box, focus ends up in a textarea
element *below* the desired edit box (the one has the onEditBoxBlur() as
it's "onblur" handler).
If I remove the editBox.focus() statement, then focus returns to the web
page itself instead.
Why is this happening and how can I fix things so that focus returns to the
desired textarea control ("editBox")?
Thanks.