Forum Moderators: open

Message Too Old, No Replies

keeping popup on top

and focus on a specific field

         

bruhaha

5:27 pm on Oct 20, 2003 (gmt 0)

10+ Year Member



Our site uses popups to handle certain requests (e.g., delete, move or rename a file from a list). So that users do not accidentally "lose" the window --e.g., by accidentally clicking outside it-- before they've finished their request, I'm forcing these popup windows to stay on top. (Of course, there is a convenient "Cancel" button for closing the window if it was opened by mistake.)

For some it is a simple matter of adding "onBlur="self.focus()" in the body tag. But in other cases the popup already includes an onLoad function that places the focus in the first form field in the window. Adding the "onBlur" above overrides this.

Any ideas of how I can force the popup to stay on top yet continue to have the popup open up with focus in a specific field/element?

MonkeeSage

9:21 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Should just be...

onblur="theelementto.focus();"

e.g.,

onblur="document.getElementById('entry').focus();"

...by focusing the element on the page, the window should receive focus as well, as the event is propigated up the DOM...I think. I'm not certain though. But it's worth a try.

Jordan

bruhaha

1:01 pm on Oct 21, 2003 (gmt 0)

10+ Year Member



by focusing the element on the page, the window should receive focus as well

Seemed so to me too, but it doesn't quite work that way. The element does get the focus --thus, if I manually switch back to that window it comes up with the cursor in that field, even if it had been moved. But the window itself does not stay on top.

I'm thinking of forcing the focus back to the page (via onBlur="self.focus()" in the body), but adding a very brief delay after which the focus is shifted to a field in the form.

(Actually, that adds another wrinkle -- I would prefer the focus end up in whichever field the user was last editing, not necessarily the first field in the form.)

korkus2000

1:06 pm on Oct 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would caution you on using window focus in events that could cause infinite loops and a real problem stopping it, except closing the window. People like windows to react the way they are use to. Sometimes we can overcomplicate something we are trying to make easier for the user.