/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Browser window centering problem

Hi,

I am trying to launching a centered browser window via a form-button using the following code…

<button type=’button’
onClick=”window.open(‘http://www.bbc.co.uk’,’testwin’,’width=400, height=400, left=(screen.availWidth-400)/2, top=(screen.availHeight-400)/2′); return false”>
Test button</button>

The new browser appears the correct height and width, but the left and top clauses are ignored.

Am I being too ambitious trying to make this code in-line? Is there any other syntax I should use or should I give-up and call a function instead (I would rather not if I can avoid it)?

I am using Firefox 3.0.17 (latest), but the same effect happens in IE7.

TIA,
Alan Harris-Reid

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangFeb 13.2010 — &lt;button type="button"
onclick="window.open('http://www.bbc.co.uk','testwin', 'width=400, height=400, left='+(screen.availWidth-400)/2+', top='+(screen.availHeight-400)/2+''); return false"&gt;
Test button&lt;/button&gt;

Firefox latest
Copy linkTweet thisAlerts:
@aharrisreidauthorFeb 13.2010 — Hi Fang,

That fix works. I reckon I might have to write a JS function anyway one day, but it's nice to know that an in-line solution is available.

Many thanks,

Alan
×

Success!

Help @aharrisreid 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.3,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...