Results 1 to 2 of 2
Thread: Window positioning woes
Jan 20, 2003, 04:14 #1
- Join Date
- Feb 2002
- 0 Post(s)
- 0 Thread(s)
Window positioning woes
I am trying to write a function that sets the position of a popup window. I was under the impression that NS uses screenX & screenY to set the position of the popup window, while IE used top & left properties.
I tried to make the script distinguish between NS and IE but I have encountered a few problems.
1. When I test it in IE it detects both methods, thus the position variable takes on the screenX/screenY format (since the secong method [if statement] follows the first). Funnily enough though it still works (even though IE doesn't support those two properties (screenX/screenY). Strange??
2. NS6 (Windows) only detects the second method thus no problems here.
3. Mozilla 1.? (Linux) detects both methods so ends up assigning variable position with the screenX/screenY properties. Not sure why it detect boths, but it works.
4. Galeon 1.? (Linux) same as Mozilla above except that the popup window wont open in the correct position. I thought Galeon was derived from Mozilla, thus if it works on Mozilla and NS6, then it should work on Galeon. What gives??
Below is a copy of the script. Can anyone see anything that might be causing the problems I mentioned above?
Kind regards, Ben
/* Calculate screen width and height */
/* Calculate browser object model and set position string accordingly */
if (document.body.clientWidth) // Browser suports IE DOM
alert('IE\nWidth '+ document.body.clientWidth +'\nHeight '+ document.body.clientHeight +'\nNSwidth '+ screen.width +'\nNSheight '+ screen.height);
screen_width = (document.body.clientWidth - 600)/2;
screen_height = (document.body.clientHeight - 300)/2;
position = 'left='+ screen_width + ', top='+ screen_height;
if (screen.width) // Browser supports NS DOM
screen_width = (screen.width - 600)/2;
screen_height = (screen.height - 300)/2;
position = 'screenX='+ screen_width +', screenY='+ screen_height;
string = temp;
features = 'width=600, height=400, ' + position;
smallWindow = window.open(string, 'Experience', features);
Experience is that thing which lets you know you've made the same mistake yet again.