/    Sign up×
Community /Pin to ProfileBookmark

Hi guys! Things are coming along well.

What I am trying to do is make this popup appear in the center of the screen.
Where it says top=300, thats good. But where left=300, is there a way to make it something like this: left=center?

Thanks

[code=html]
<script type=”text/javascript”>
var win
function openPopup(url) {
var features = ‘left=300,top=300,width=300,height=300,scrollbars=0,status=0’;
var url=”http://djshawnmichaels.com/popup.php”;

win = window.open(url, ‘opener’, features);
}
</script>
[/code]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@herodote92Oct 13.2005 — You have to play with the screen.width, and position the 'left' value to the half of the space remaining, i.e (screen.width - [width of the popup] ) / 2, preferably rounded or floored.
Copy linkTweet thisAlerts:
@comptech520authorOct 13.2005 — Thanks, i just didnt know if there was a general way to do it
Copy linkTweet thisAlerts:
@MjhLkwdOct 13.2005 — [CODE]<HTML>
<Head>
<Script Language=JavaScript>

var popWin = "";

function openwin(url,strWidth,strHeight){

if (popWin != ""){popWin.close()}
var leftStr = (screen.width-strWidth)/2;
var topStr = (screen.height-strHeight)/2-50;
var windowProperties = "toolbar=no,menubar=no,scrollbars=no,stausbar=no,height="+strHeight+",width="+strWidth+",left="+leftStr+",top="+topStr+"";
popWin = window.open(url,'newWin',windowProperties);
}

</Script>
</Head>
<Body>
<a href=javascript:openwin('1/1.html',300,225)>Open a centered popup window</a>
</Body>
</HTML>[/CODE]
×

Success!

Help @comptech520 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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