SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2002
    0 Post(s)
    0 Thread(s)

    Window positioning woes

    Hi All

    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

    PHP Code:
    function PopUp(temp)
    /* 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;

    Experience is that thing which lets you know you've made the same mistake yet again.

  2. #2
    SitePoint Member
    Join Date
    Jan 2003
    0 Post(s)
    0 Thread(s)
    I just found your question I too have the same issue... I want mine to open towards the middle. I am sorry I didn't read all of your post -- any answer?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts