本文介绍了打开新窗口,并使用JavaScript进行超链接控制以获取焦点.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用Target ="_blank"属性单击超链接控件时,我想打开一个新窗口,新窗口将被聚焦.
它适用于Google和其他网站,我也可以处理自己的Pages来集中注意力,例如< bodyönload="this.focus();">
但是对于http://yahoo.co.in,它在新窗口中打开,但在父窗口后面打开.
请帮助我如何用javascript编写代码以集中精力.
感谢&问候
Sudhakar
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
推荐答案
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
这篇关于打开新窗口,并使用JavaScript进行超链接控制以获取焦点.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!