Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to open a new window when i click on hyperlink control by using Target = "_blank" property and the new window will be get focused.

It works for Google and other websites and i also handle my own Pages to get focused like <body önload="this.focus();">

But for the http://yahoo.co.in its opened in the new window but it opens behind the parent window.

Please help me how to write a code in javascript to get focused.

Thanks & Regards
Sudhakar
Posted
Updated 12-Jun-11 23:43pm
v2

Hi,All

At last i found the solution for this.

Calling The SetTimeOut() method passing focus() as a function will solve the issue.

My Code Is Like:

function setFocus() {
var grid;
grid = igtbl_getGridById('<%=OfflineReports.ClientID%>');
var actRow = igtbl_getActiveRow('<%=OfflineReports.ClientID%>');
var hypId = actRow.Id;
var hypctrl = document.getElementById(hypId);
var hlkurl = hypctrl.all;
if (hlkurl != null) {
var url = hlkurl[4];
var win = window.open(url);
setTimeout(function() { win.focus(); }, 1000);
}
}
Here i used ultra grid instead you can use Document.GetElementById("<%hypLink.ClientID%>");
 
Share this answer
 
XML
Hi,All

At last i found the solution for this.

Calling The SetTimeOut() method passing focus() as a function will solve the issue.

My Code Is Like:

function setFocus() {
var grid;
grid = igtbl_getGridById('<%=OfflineReports.ClientID%>');
var actRow = igtbl_getActiveRow('<%=OfflineReports.ClientID%>');
var hypId = actRow.Id;
var hypctrl = document.getElementById(hypId);
var hlkurl = hypctrl.all;
if (hlkurl != null) {
var url = hlkurl[4];
var win = window.open(url);
setTimeout(function() { win.focus(); }, 1000);
}
}
Here i used ultra grid instead you can use Document.GetElementById("<%hypLink.ClientID%>");
Improve solution   Permalink     |  Posted
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900