document.focus not working correctly

M

marty.overdear

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?
 
C

Curtis.DanielN

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?
 
D

Daz

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.
 
M

marty.overdear

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?
 
M

marty.overdear

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
 
M

marek_hubatka

Maybe you should call the focus function from the parent window.

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

marty.overdear

I tried it like below, but it is still not working correctly.
Thx for the support, keep it coming please
 
M

marty.overdear

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top