/    Sign up×
Community /Pin to ProfileBookmark

centering pop-up for a beginner

i realize this is a common question and there is a webpage here explaining how to do it. but i don’t want to change all of my links to declare width and height. in other words how could adjust this function to open the pop-ups centered without touching my link coding?

<script language=”JavaScript”>
function mapshot(link)
{ window.open(link,’newmap’,’titlebar=no,width=700,height=525,scrollbars=no’); }
</script>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@steelersfan88Feb 26.2004 — Change your function to:

[code=php]<script language="JavaScript">

function mapshot(link) {
newWin = window.open(link,'newmap','titlebar=no,width=700,height=525,scrollbars=no');
var x = (screen.width - 700)/2
var y = (screen.height - 525)/2
newWin.moveTo(x,y)
}

</script>[/code]
Of course, this will produce an error on pages off your server.

Of course, this is assuming you call the function somewhat like this:

[code=php]<a href="myPage.htm" onclick="mapshot(this.href);return false;">myPage.htm</a>[/code]
×

Success!

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