473,386 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

document.focus not working correctly

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
7 13064
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Paul Thompson | last post by:
How do I determine in JavaScript the name of the object that focus is on?
4
by: Scott Navarre | last post by:
Hi, I have Red Hat 8.0 and have the default Mozilla browser that comes with it. I am programming in javascript and have come across something problematic. Given the following code: <HTML>...
8
by: lawrence | last post by:
I'm a beginner with Javascript and especially cross-browser Javascript. I got this working in IE, but not in Netscape 7. It seems like, in Netscape, every time I click on a button, the focus shifts...
1
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
1
by: Raj | last post by:
Hi, I have the following problem. I am displaying and printing a PDF file that is generated by my Application server. The print dialogs comes up correctly for the small PDF for the larger PDFs...
2
by: Raj | last post by:
Hi, I have the following problem. I am displaying and printing a PDF file that is generated by my Application server. The print dialogs comes up correctly for the small PDF for the larger PDFs...
5
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate...
8
by: makunag | last post by:
Didn't get answer with google and in my regular forum. Came across this site and posting here. Your help will be highly appreciated ! Our application have frames - MainNav, TaskNave and Content....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.