PDA

View Full Version : Central position


Luis
12-09-2002, 02:46 PM
Hy guys, i'de like to ask if somebody can help me with a script code for html, i have a 800x450pxl window and i would like that it opens at a central position on screen. I've already saw some toturials, but that cames be to hard for to understand how to use one my project.

binkyboo
12-09-2002, 02:54 PM
Have you played around with top=whatever,left=whatever.

example:

onClick="MM_openBrWindow('m1_pop/pop1p4.html','pop1m1p4','scrollbars=yes,resizable= yes,width=700,height=600,top=80,left=280')"

I don't know if this is what you're after but the top and left options allow you to position your window. The only problem is you can only center it for a specified resolution.

tg
12-09-2002, 02:55 PM
try:

<!--
function popWin(){
var moveToX, moveToY;
moveToX=(window.screen.availWidth-800)/2;
moveToY=(window.screen.availHeight-450)/2;
var tools="location=no,scrollbars=no,resize=no,menubar=no,sta tusbar=no,toolbar=no,menubar=no,titlebar=no,resize able=no";
var features="width=800,height=450";
var opts=tools + ',' + features;
var popup=window.open("main.02.cfm?dept=<cfoutput>#URLEncodedFormat(URL.dept)#</cfoutput>","scorecard",opts);
popup.moveTo(moveToX,moveToY);
popup.focus();
}
//-->
</script>
</HEAD>
<BODY bgcolor="#007AA5" onLoad=popWin()>


just ignore the cold fusion <cfoutput> tags.

tg
12-09-2002, 02:56 PM
ahhh.. binkyboo snuck one in there.

binkyboo
12-09-2002, 02:58 PM
But yours is much more dynamic! I tried it and it works flawlessly on whatever resolution you choose. Thanks tg!!

Luis
12-09-2002, 03:04 PM
I´m asking this because i've been seeing some browsers options at http://www.dynamicdrive.com/dynamicindex8/index.html, but i have 800x450pxl window on my project, may i use an fullscreen window without scroolbar and toolbar or use my window size but centraled at our screens?
I can't remenber where did i saw an html centralized on our screens like a lot of people uses. I'll try your code.

Luis
12-09-2002, 03:06 PM
Thanks Tg

ssjogus
12-10-2002, 03:37 AM
if i change the window size of a new opening window, like:

var features="width=150,height=150";

the new window is not coming in the center of the browser (600*800)

ssjogus.

superpuppets
12-10-2002, 05:08 AM
if i where u i would use a window of 770 * 400 becuse it is the best size for 800 600 and it looks good on 1024* 768 too

tg
12-10-2002, 02:12 PM
Originally posted by ssjogus
if i change the window size of a new opening window, like:

var features="width=150,height=150";

the new window is not coming in the center of the browser (600*800)

ssjogus.

make sure you change the values in these lines also:

moveToX=(window.screen.availWidth-150)/2;
moveToY=(window.screen.availHeight-150)/2;

ssjogus
12-11-2002, 03:03 AM
ok ok, it' working now. thanks tg!

after making changes in the code, it' working.

moveToX=(window.screen.availWidth-150)/2;
moveToY=(window.screen.availHeight-150)/2;

But then again , the new window appears first in the left corner for 1\2 seconds, and then it comes to the center of the page, why so?

ssjogus.

Luis
12-16-2002, 01:27 AM
It seems me that i´ll have to use your code ( tg ) on my central popwindow?, So and if i have an index.html that generates that popwindow automatacly!!:)