473,387 Members | 1,512 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,387 software developers and data experts.

Parent window keeps the focus! grrr

Hi everyone,
I have this problem hope you could help me...
I have an A.aspx page with a button, when I click the button I would
like to open another window with containing B.aspx. The problem is
that the window B.aspx appears fine but the focus returns to the
parent (A.aspx), I would like the focus in B.aspx window.
When I click the button on A.aspx I execute the following code:

private void btMyButton_Click(object sender, System.EventArgs e)
{
Session["LineFileCode"] = tbLineFileCode.Text.Trim();
OpenWindow("B.aspx");
}

OpenWindow his a method:

public void OpenWindow(string strURL)
{
string sb;
sb = "<script language=javascript>";
sb = sb + "w=window.open('" + strURL + "','PopUp',
'width=200,height=200,scrollbars=yes,toolbar=no,me nubar=no');";
sb = sb + "w.focus();";
sb = sb + "</script>";

if (!this.IsStartupScriptRegistered("OpenWindow"))
{
this.RegisterStartupScript("OpenWindow", sb.ToString());
}
}

Can you please give me some clue of what am I doing wrong?
Thanks a lot in advance!

Elsa
Nov 18 '05 #1
2 1803
your setting the focus too soon. better to have the popup set the focus
itself.

note: with the next security release of IE, your code will not work anyway,
as it will be idendified as a unsolicated popup.
-- bruce (sqlwork.com)


"Elsa Luiz" <el*******@hotmail.com> wrote in message
news:59*************************@posting.google.co m...
Hi everyone,
I have this problem hope you could help me...
I have an A.aspx page with a button, when I click the button I would
like to open another window with containing B.aspx. The problem is
that the window B.aspx appears fine but the focus returns to the
parent (A.aspx), I would like the focus in B.aspx window.
When I click the button on A.aspx I execute the following code:

private void btMyButton_Click(object sender, System.EventArgs e)
{
Session["LineFileCode"] = tbLineFileCode.Text.Trim();
OpenWindow("B.aspx");
}

OpenWindow his a method:

public void OpenWindow(string strURL)
{
string sb;
sb = "<script language=javascript>";
sb = sb + "w=window.open('" + strURL + "','PopUp',
'width=200,height=200,scrollbars=yes,toolbar=no,me nubar=no');";
sb = sb + "w.focus();";
sb = sb + "</script>";

if (!this.IsStartupScriptRegistered("OpenWindow"))
{
this.RegisterStartupScript("OpenWindow", sb.ToString());
}
}

Can you please give me some clue of what am I doing wrong?
Thanks a lot in advance!

Elsa

Nov 18 '05 #2
Thank you Bruce for your reply but that was not the problem. Brian
Bond (thanks Brian!) sent me an email saying that SmartNavigation
turned on can cause this behaviuor and he was rigth, I had
SmartNavigation turned on, I turned it off and it worked, I have now
the focus on my child window. But I also winned another problem :(
When in my child I click on a button I execute the following code:

RefreshParentWindow();
CloseWindow();

public void RefreshParentWindow()
{
string sb;
sb = "<script language=javascript>";
sb = sb + "window.opener.location.reload();";
sb = sb + "</script>";

if (!this.IsStartupScriptRegistered("RefreshParentWin dow"))
{
this.RegisterStartupScript("RefreshParentWindow", sb.ToString());
}
}

public void CloseWindow()
{
string sb;
sb = "<script language=javascript>";
sb = sb + "window.close();";
sb = sb + "</script>";

if (!this.IsStartupScriptRegistered("CloseWindow"))
{
this.RegisterStartupScript("CloseWindow", sb.ToString());
}
}

The problem is that when I clicked the button my browser keep asking
me:
"The page cannot be refreshed without resending the information. Click
Retry to send the information again, or clcik cancel to return to the
page that you were trying to view."
If I click Retry my Child window appears again, if I click cancel also
:(

Any thougths?
Thanks!
Elsa
"bruce barker" <no***********@safeco.com> wrote in message news:<uf**************@tk2msftngp13.phx.gbl>...
your setting the focus too soon. better to have the popup set the focus
itself.

note: with the next security release of IE, your code will not work anyway,
as it will be idendified as a unsolicated popup.
-- bruce (sqlwork.com)


"Elsa Luiz" <el*******@hotmail.com> wrote in message
news:59*************************@posting.google.co m...
Hi everyone,
I have this problem hope you could help me...
I have an A.aspx page with a button, when I click the button I would
like to open another window with containing B.aspx. The problem is
that the window B.aspx appears fine but the focus returns to the
parent (A.aspx), I would like the focus in B.aspx window.
When I click the button on A.aspx I execute the following code:

private void btMyButton_Click(object sender, System.EventArgs e)
{
Session["LineFileCode"] = tbLineFileCode.Text.Trim();
OpenWindow("B.aspx");
}

OpenWindow his a method:

public void OpenWindow(string strURL)
{
string sb;
sb = "<script language=javascript>";
sb = sb + "w=window.open('" + strURL + "','PopUp',
'width=200,height=200,scrollbars=yes,toolbar=no,me nubar=no');";
sb = sb + "w.focus();";
sb = sb + "</script>";

if (!this.IsStartupScriptRegistered("OpenWindow"))
{
this.RegisterStartupScript("OpenWindow", sb.ToString());
}
}

Can you please give me some clue of what am I doing wrong?
Thanks a lot in advance!

Elsa

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Randell D. | last post by:
Folks, I'm working on a contact name/address database whereby a slimed down list is shown in the main window. When a record is selected, the complete record is displayed in a new window via a...
3
by: Randell D. | last post by:
I have a parent window that calls window.open("myurl","mywindowname"); I would like to do the all (or some) of the following - can someone help? From the parent, close the child and... From...
1
by: Tomas Vera | last post by:
Hello All, I'm working on a web app that will simulate a Windows app. One of the items that I've trouble reproducing is the parent/child interaction that might occur between a windo and popup...
0
by: IndyChris | last post by:
I've got a button my webpage that when clicked will open another window. Different criteria on the page will deteremine which window gets opened when the button is clicked. I have a switch...
4
by: John Kotuby | last post by:
Hello all, I am new to Javascript and have been trying to find an answer to this problem. After searching 3 books and searching postings, I am going to ask this newgroup. I am using a pre-built...
1
by: pingalkar | last post by:
Hi, In my application, I call one popup winodow by using this link.. <a href="#" onClick="return showWindow('1','XYZ');"> <img src="images/magnifier.gif" ALT="Chemicals"...
1
by: elizayiu | last post by:
Hi, I need to write a webpage which does the following: - open up a window and pass parameters into it (i.e. need to call showModalDialog() or showModelessDialog()) - contains jscript to...
4
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase...
1
by: varunvashishth | last post by:
hi, I'm facing a problem with displaying a child jsp on top of parent jsp. on clicking a link in parent jsp the child jsp opens up and it has some list of values and other textboxes which gets...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.