By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,583 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

document.focus not working correctly

P: n/a
I am opening a new window using window.open. I need the new window to
open on top of the parent everytime. I cannot use onBlur b/c the user
will need to click back to the parent for information. I just need it
to open on top everytime. I am using this line in the body
<body onload="window.focus()" bgColor="#0077d6"
ms_positioning="GridLayout">

The window.focus doesn't work everytime. I can open it and it may
work. I will completely close the app, start it again and it will not
work, but the next time it might. It is inconsistent. How do I get it
to not give focus back to the parent after it opens?
How can I get the parent to relinquish focus?

Nov 17 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Just one quick question for clarification: is the parent window
finished loading or does the parent window have anything running when
you open the child window?

Nov 17 '06 #2

P: n/a
Daz

marty.overd...@intergraph.com wrote:
I am opening a new window using window.open. I need the new window to
open on top of the parent everytime. I cannot use onBlur b/c the user
will need to click back to the parent for information. I just need it
to open on top everytime. I am using this line in the body
<body onload="window.focus()" bgColor="#0077d6"
ms_positioning="GridLayout">

The window.focus doesn't work everytime. I can open it and it may
work. I will completely close the app, start it again and it will not
work, but the next time it might. It is inconsistent. How do I get it
to not give focus back to the parent after it opens?
How can I get the parent to relinquish focus?
I can't see what the problem is. If I were faced with that situation, I
would try putting
<script>
window.focus();
</script>
right at the end of the HTML after the body.
Or perhaps trying to call the script externally, and placing
window.focus() at the end of the external script.
Another method which may or may not work, would be to try:
<body onload="this.window.focus();" bgColor="#0077d6"
ms_positioning="GridLayout">
or
<body onload="this.focus();" bgColor="#0077d6"
ms_positioning="GridLayout">

I can't confirm any of these will work, but if any of them do, please
post back as I am interested in knowing.

Best wishes.

Daz.

Nov 17 '06 #3

P: n/a
I am posting from a button on a grid. I checked all the grid events to
see if they were firing after the window appears, and they were not. I
tried this.focus, and this.window.focus, all with the same results.
I am assuming that the parent window is doing something to regain
focus. How can I relinquish focus from the parent?

Nov 17 '06 #4

P: n/a
I assume that the parent is regaining focus somehow. I am launching
the new window from a grid, and I don't see anything happening after I
launch the button. I put a debug in it, and some events fire on the
parent after the command to open the window is run, but none run after
the actual window appears.
I tried the this.focus and this.window.focus and they react the same
as it did before

Nov 17 '06 #5

P: n/a
Maybe you should call the focus function from the parent window.

<script>
var xyz = window.open(...);
xyz.focus();
</script>

ma************@intergraph.com schrieb:
I assume that the parent is regaining focus somehow. I am launching
the new window from a grid, and I don't see anything happening after I
launch the button. I put a debug in it, and some events fire on the
parent after the command to open the window is run, but none run after
the actual window appears.
I tried the this.focus and this.window.focus and they react the same
as it did before
Nov 17 '06 #6

P: n/a
I tried it like below, but it is still not working correctly.
Thx for the support, keep it coming please

ma***********@gmx.de wrote:
Maybe you should call the focus function from the parent window.

<script>
var xyz = window.open(...);
xyz.focus();
</script>
Nov 17 '06 #7

P: n/a
It is a button in a datagrid. I tried the thing below in the code
behind, not in the actual HTML b/c I don't know where to add it. I
don't want it envoked unless the button has been pressed, which fires
an event. All of the coding for the events is not done in HTML, so I
don't have a good example of doing it here. Here is the definition for
the button of the datagrid.
<asp:ButtonColumn Text="Comments" ButtonType="PushButton"
CommandName="Comments" ></asp:ButtonColumn>

I would like to launch the new window when this is clicked. How do I
do it in the HTML?
marty.overd...@intergraph.com wrote:
I tried it like below, but it is still not working correctly.
Thx for the support, keep it coming please

ma***********@gmx.de wrote:
Maybe you should call the focus function from the parent window.

<script>
var xyz = window.open(...);
xyz.focus();
</script>
Nov 17 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.