By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

Centering Browser Pop-Up Window?

P: n/a
Joe
Hi- What do I need to add to this to make it pop up in the centre of the
screen:

<SCRIPT LANGUAGE="JavaScript">
function pop() {
window.open("current.htm","","height=200,width=200 ,left=0,top=0");
}
</script>

Thanks - Joe
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 01/09/2003
Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Joe" <so****************@grapevine.net> writes:
Hi- What do I need to add to this to make it pop up in the centre of the
screen:
Don't!
<URL:http://www.infimum.dk/HTML/JSwindows.html#ref_3_3>

If you insist, see below.
<SCRIPT LANGUAGE="JavaScript">
<script type="text/javascript">
The type attribute is required in HTML 4
function pop() {
var left = Math.floor((screen.availWidth - 200) / 2);
var top = Math.floor((screen.availHeight - 200) / 2);
window.open("current.htm","","height=200,width=200 ,left="+left+",top="+top);
}


/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
Joe
> > Hi- What do I need to add to this to make it pop up in the centre of the
screen:
Don't!
<URL:http://www.infimum.dk/HTML/JSwindows.html#ref_3_3>

If you insist, see below.
<SCRIPT LANGUAGE="JavaScript">


<script type="text/javascript">
The type attribute is required in HTML 4
function pop() {


var left = Math.floor((screen.availWidth - 200) / 2);
var top = Math.floor((screen.availHeight - 200) / 2);

window.open("current.htm","","height=200,width=200 ,left="+left+",top="+top);
}


/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'


Thanks
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 01/09/2003
Jul 20 '05 #3

P: n/a
Joe
Any idea how to add a scroll bar while I'm here?

<script type="text/javascript">
function pop() {
var left = Math.floor((screen.availWidth - 600) / 2);
var top = Math.floor((screen.availHeight - 300) / 2);
window.open("current.htm","","height=300,width=600 ,left="+left+",top="+top);
}
</script>

Thanks - Joe
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 01/09/2003
Jul 20 '05 #4

P: n/a
"Joe" <so****************@grapevine.net> writes:
Any idea how to add a scroll bar while I'm here?


window.open("current.htm","","height=300,width=600 ,left="+left+
",top="+top+",scrollbars=yes,resizable=yes");

See: <URL:http://www.infimum.dk/HTML/JSwindows.html#ref_3_2>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #5

P: n/a
In article <1x**********@hotpop.com>, Lasse Reichstein Nielsen <lr*@hotpop.com>
writes:
var left = Math.floor((screen.availWidth - 200) / 2);
var top = Math.floor((screen.availHeight - 200) / 2);

window.open("current.htm","","height=200,width=20 0,left="+left+",top="+top);


And even that is not sure to work. My browser gives screen.availWidth as 2048,
yet my displays don't allow window spanning, so it can only use 1024 on either
monitor. Gives a nasty result when run as above :(
--
Randy
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.