/    Sign up×
Community /Pin to ProfileBookmark

Issue w/ window.open/focus

I am trying to resolve an issue w/ window.open and window.focus. I have a page that is used to request reports by sending a request to a Crystal Server page. The user can request multiple reports at a time. The following code is used to generate the reports:

function callCrystal(){
//var win;
var features = new String(“”);
features = features + ‘toolbar=no,’;
features = features + ‘scrollbars=yes,’;
features = features + ‘location=no,’;
features = features + ‘statusbar=no,’;
features = features + ‘menubar=no,’;
features = features + ‘resizable=yes,’;
features = features + ‘width=500,’;
features = features + ‘height=400,’;

if(frmCrystalParams.txtParams.length>1)
{
for(i=0;i<frmCrystalParams.txtParams.length;i++)
{
var x= frmCrystalParams.txtParams[i].value;
win = window.open(‘http://<%=ConfigurationSettings.AppSettings[“CRYSTAL_SERVER”]%>/getparameters.asp?’+x,’popup’+i,features);
if (win.open) win.focus();
}
}
else
{
var x= frmCrystalParams.txtParams.value; win = window.open(“http://<%=ConfigurationSettings.AppSettings[“CRYSTAL_SERVER”]%>/getparameters.asp?”+x,”popup”,features);
if (win.open) win.focus();
}

}

We are trying to have the popup window maintain focus, but it doesnt work.
Focus returns to the page that created the new window.

The win.focus appears to be ignored. this is ie6

Does anyone have any tips? thanks.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceApr 06.2005 — You're probably trying to take control of the popup window too soon. IE doesn't like you trying to access the window before IE is finished opening it. Use [b]setTimeout[/b] to execute a function that performs the focus when the timer pops. In this case, of course, your window pointer variable will have to be a global variable.
×

Success!

Help @smascho spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...