View Full Version : Able to set the position when u open up the window?
yeen83
08-13-2002, 05:10 PM
when u open a window will u be able to set the position of the new window?
Because it might be a small window.or will it able to set the new window visibility as hidden?
beetle
08-13-2002, 05:17 PM
The function in this post (http://www.codingforums.com/showthread.php?s=&threadid=3950) lets you set the position
yeen83
08-13-2002, 05:29 PM
newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',features=' + newfeatures + '');
so the top='+window_top+ -->tis wan is to set the location of the window?
beetle
08-13-2002, 05:35 PM
Well, that function is acutally a bit confusing. Here use this instead...function popWin(nUrl, w, h, t, l)
{
var features = "";
features += 'width='+w;
features += ',height='+h;
features += ',top='+t;
features += ',left='+l;
window.opent(nUrl,'',features);
} Then to open the window, call thispopWin('page.htm',300,400,100,100);This will open 'page.htm' in a popup window that is 300px wide, 400px high, 100px left, and 100px from the top.
micros1
08-13-2002, 10:26 PM
Can I add to this question,
different screen sizes will cause:
---------------
100px left, and 100px from the top
---------------
to be different on larger monitors, so how can a window be placed from the - right and bottom respectively?
beetle
08-13-2002, 10:34 PM
Can't be done directly, but you can use some screen measurements and basic arithmetic to get it right. I'll show the example acutally using variables for right and bottom.function popWin(nUrl, w, h, r, b)
{
var features = "";
features += 'width='+w;
features += ',height='+h;
var t = screen.height-(h+b);
var l = screen.width-(w+r);
features += ',top='+t;
features += ',left='+l;
window.opent(nUrl,'',features);
}
This will now open a window (using the same call from before) that is 300x400 pixels, 100px from the right and 100px from the bottom.
micros1
08-14-2002, 02:39 AM
nice work Beetle,
U mention..
------------------------
Can't be done directly,
------------------------
Are you refering to this command..
<body onLoad="moveTo(0,0);">?
I ask you this because, well your good at this and
well I have used a pop-up (layer would not work) placed over part of my fLASH presentation (100% by 100%) . The borderless window must stay at the right corner. I will post my url to see what I have done, this may require custom work?
beetle
08-14-2002, 02:50 AM
moveTo(0,0) is more accurately described as moveTo(x,y) or moveTo(l,t). Since you already have the calculations for figuring from bottom and right, you should be able to do this.
micros1
08-14-2002, 05:45 AM
Im unable to cipher this java script into my webpage, as seen here it is a little bit different circumsyances.
microhydrin.sun-cell.com
any ideas?
beetle
08-14-2002, 02:52 PM
I see. What you are trying to accomplish isn't exactly simple. I think you need to:
1) Detect when the window is resized
2) Move popoup accordingly
3) Set focus to popup
micros1
08-14-2002, 05:03 PM
Good idea Beetle..
This should work..
Screen Resolution Redirect
<script language="Javascript"><!--
if (screen.width <= 640) {
document.location = "640x480.htm";
}
else if (screen.width <= 800) {
document.location = "800x600.htm";
}
else if (screen.width <= 1024) {
document.location = "1024x768.htm";
}
if (screen.width > 1024) {
document.location = "unabletoguess.html";
}
//-->
</script>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.