473,320 Members | 2,088 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,320 software developers and data experts.

Attributes.Add("onclick", ... & window.Focus()

GD
I have an ImageButton in a Repeater, and in the Repeater's
OnItemDataBound event, I'd like to add some code that will let the
ImageButton open a URL in a new window.

This is what I have in my Repeater's OnItemDataBound event:

ImageButton oImageButton =
((ImageButton)e.Item.FindControl("ibtnNewWindow")) ;
string sUrl = "http://www.cnn.com"; // Just as an example
string sWindow = string.Concat(@"javascript:window.open(',", sUrl, "',
'_blank', 'toolbars=no,status=no,menubar=no,location=no')");
oImageButton.Attributes.Add("onclick", sWindow);

The works great, except that the new window doesn't retain focus when
it's opened.

How can I use window.Focus() to ensure that the new window receives
focus?

Thanks

Feb 24 '06 #1
2 5452
Try

var newWindow = window.open(sUrl, , '_blank',
'toolbars=no,status=no,menubar=no,location=no');
newWindow.focus();

HTH

Elton Wang

"GD" wrote:
I have an ImageButton in a Repeater, and in the Repeater's
OnItemDataBound event, I'd like to add some code that will let the
ImageButton open a URL in a new window.

This is what I have in my Repeater's OnItemDataBound event:

ImageButton oImageButton =
((ImageButton)e.Item.FindControl("ibtnNewWindow")) ;
string sUrl = "http://www.cnn.com"; // Just as an example
string sWindow = string.Concat(@"javascript:window.open(',", sUrl, "',
'_blank', 'toolbars=no,status=no,menubar=no,location=no')");
oImageButton.Attributes.Add("onclick", sWindow);

The works great, except that the new window doesn't retain focus when
it's opened.

How can I use window.Focus() to ensure that the new window receives
focus?

Thanks

Feb 25 '06 #2
GD
Thank you Elton!

Feb 28 '06 #3

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

Similar topics

2
by: Fred Snider | last post by:
Help! Opening a new window using the window.open( ) command works great for opening new windows and having them on top and having the focus. The window.focus command brings any existing...
1
by: CES | last post by:
All, I'm trying to test if a browser is configured so that I can use popup windows or if it has a popup blocker installed... the only solution I was able to think of, was one that would pop up a...
5
by: Wei | last post by:
I need the current window stay on focus. The user will have to click on exit button to exit the window. How can I do this in asp.net in C#? Thank you
2
by: Wei | last post by:
I need the current window stay on focus. The user will have to click on exit button to exit the window. When I use the following code, I got an error: "Not implemented" Code: private void...
3
by: Frances | last post by:
this is for a browser window that contains a chat app that is an applet... when browser window is not in focus I would like users to somehow get notified when a message arrives, more or less like...
4
by: Roger | last post by:
Hi, I am confused about the differences between this.window.focus(), window.focus(), and this.focus(). I want to use the calls in a <body onload="..."tag. What are the differences between...
4
by: Jason | last post by:
Hi, Here's the scenario: I have a web application that has window A and window B. A user has both window A and B open - window A is in the foreground and window B is behind it. If the...
3
by: acehigh1983 | last post by:
Is it possible to focus a window in firefox and safari?? i have a webpage that opens another window, it then focuses on the original window (the new window that opened now behind it in the...
4
by: Spizzat2 | last post by:
I'm trying to figure out a workaround to a minor annoyance that I'm coming up with while coding a site. I've got some keyboard shortcuts set up for the site via javascript, and when I press escape,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.