/    Sign up×
Community /Pin to ProfileBookmark

centering pop up window

The following script displays a pop up window with an image on it. However the problem that I see is that the window does not pop up at the center of the screen.

<HTML>
<Head>
<Script Language=”JavaScript”>

function openFullSize(Pix)
{
nullIMG.src = Pix;
wStr = nullIMG.width;
offsetW = wStr;
wStr = wStr+20;
wStr = “width=”+wStr;
hStr = nullIMG.height;
offsetH = hStr;
hStr = hStr+20;
hStr = “height=”+hStr;
lStr = (screen.width-50-offsetW)/2;
lStr = “left=”+lStr;
tStr = (screen.availHeight-90-offsetH)/2;
tStr = “top=”+tStr;

window.open(Pix,”FullSize”,”toolbar=0,status=0,scrollbars=yes, “+tStr+”,”+lStr+”,”+wStr+”,”+hStr+” “);

}

function buildSupport()
{
styleStr = “<Style> .placeHolder {Position:Absolute;Top:-2000;};</Style>”;
divStr = “<Div class=placeHolder><IMG Src=Null ID=nullIMG></Div>”
document.write(styleStr);
document.write(divStr);
}

buildSupport();

</Script>

<Body>
<center>
<H3>Thumbnail link to clean, dynamically sized window</H3>
<a href=javascript:openFullSize(‘screenshot2.jpg’)><img src=’screenshot2.jpg’ width=’140′ height=’105′ alt=’Click to enlarge’></a>
</center>
</Body>
</HTML>

How do I solve the problem?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@dthurman1432Jun 19.2006 — by adding an appropraite left and top spacing attribute.

window.open(Pix,"FullSize","toolbar=0,status=0,scrollbars=yes,left=250,top=100, "+tStr+","+lStr+","+wStr+","+hStr+" ");
Copy linkTweet thisAlerts:
@solomon_13000authorJun 19.2006 — left and top has been specified.

I have replaced:

lStr = (screen.width-50-offsetW)/2;

lStr = "left="+lStr;

tStr = (screen.availHeight-90-offsetH)/2;

tStr = "top="+tStr;

to:

lStr = (screen.width/2 - offsetW/2);

lStr = "left="+lStr;

tStr = (screen.height/2 - offsetH/2);

tStr = "top="+tStr;
×

Success!

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