/    Sign up×
Community /Pin to ProfileBookmark

this.window.focus()

I have a script that opens a report in a new browser window (via target=’_blank’). Unfortunately, in all browsers, it opens in the background.

No… it’s NOT opened via pop-up, nor is it practical to open it via pop-up.
It’s also not practical to give the new window a name (target=’name’) because it is possible for a user to open multiple such windows.

The script that loads into the new window needs to contain some javascript that focuses the browser onto that window, bringing it to the foreground.

In that new window, I’ve tried:
this.window.focus()
this.focus()
window.focus()

I’ve tried all of the above:
in an onLoad within the body tag (<body onLoad=’this.window.focus()’>
within a javascript block at the end of the script (<script type=’text/javascript>this.window.focus()</script>)

No combination has worked.

Any suggestions?

Thanks
CTB

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@WolfShadeJun 03.2011 — window.onload = this.focus();
×

Success!

Help @chestertb 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.21,
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,
)...