Can someone help e debug this popup window script please?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Don

    #1

    Can someone help e debug this popup window script please?

    Hi,

    I have the following script that displays a popup window centered in the
    middle of the screen. I am getting a script error in both IE and Netscape
    but I don't know what it means. Thanks in advance.

    The error is
    ------------
    Error: win has no properties
    Line 13 below ( win.window.focu s(); )

    The code is
    ------------
    var win= null;
    function newWindow(mypag e,myname,w,h,sc roll) {
    var winl = (screen.availWi dth-w)/2;
    var wint = (screen.availHe ight-h)/2;
    var settings ='height='+h+', ';
    settings +='width='+w+', ';
    settings +='top='+wint+' ,';
    settings +='left='+winl+ ',';
    settings +='scrollbars=' +scroll+',';
    settings +='resizable=ye s';
    win=window.open (mypage,myname, settings);
    if(parseInt(nav igator.appVersi on) >= 4)
    win.window.focu s();
    if (!win.opener)
    win.opener = self;
    }


  • F. Da Costa

    #2
    Re: Can someone help e debug this popup window script please?

    Don wrote:[color=blue]
    > Hi,
    >
    > I have the following script that displays a popup window centered in the
    > middle of the screen. I am getting a script error in both IE and Netscape
    > but I don't know what it means. Thanks in advance.
    >
    > The error is
    > ------------
    > Error: win has no properties
    > Line 13 below ( win.window.focu s(); )[/color]
    I'm no specialist but the win.window.focu s() seems rather odd (to me).
    Why not win.focus() (y'v got the variable).
    Otherwise I'd set a breakpoint below win=... to see what has happened.

    F DCG[color=blue]
    >
    > The code is
    > ------------
    > var win= null;
    > function newWindow(mypag e,myname,w,h,sc roll) {
    > var winl = (screen.availWi dth-w)/2;
    > var wint = (screen.availHe ight-h)/2;
    > var settings ='height='+h+', ';
    > settings +='width='+w+', ';
    > settings +='top='+wint+' ,';
    > settings +='left='+winl+ ',';
    > settings +='scrollbars=' +scroll+',';
    > settings +='resizable=ye s';
    > win=window.open (mypage,myname, settings);
    > if(parseInt(nav igator.appVersi on) >= 4)
    > win.window.focu s();
    > if (!win.opener)
    > win.opener = self;
    > }
    >
    >[/color]

    Comment

    • kaeli

      #3
      Re: Can someone help e debug this popup window script please?

      In article <o49Pb.54184$nl 2.48073@news01. bloor.is.net.ca ble.rogers.com> ,
      don-nospam@rogers.c om enlightened us with...[color=blue]
      > Hi,
      >
      > I have the following script that displays a popup window centered in the
      > middle of the screen. I am getting a script error in both IE and Netscape
      > but I don't know what it means. Thanks in advance.
      >
      > The error is
      > ------------
      > Error: win has no properties
      > Line 13 below ( win.window.focu s(); )[/color]

      win is a window object. There is no window property of a window object,
      AFAIK.
      [color=blue]
      > win=window.open (mypage,myname, settings);
      > if(parseInt(nav igator.appVersi on) >= 4)
      > win.window.focu s();[/color]

      win.focus() or win.document.fo cus()


      --
      --
      ~kaeli~
      A little rudeness and disrespect can elevate a meaningless
      interaction to a battle of wills and add drama to an
      otherwise dull day.



      Comment

      • kaeli

        #4
        Re: Can someone help e debug this popup window script please?

        In article <o49Pb.54184$nl 2.48073@news01. bloor.is.net.ca ble.rogers.com> ,
        don-nospam@rogers.c om enlightened us with...

        [color=blue]
        > The error is
        > ------------
        > Error: win has no properties
        > Line 13 below ( win.window.focu s(); )
        >[/color]
        Also, you don't check for null before you try
        [color=blue]
        > win=window.open (mypage,myname, settings);
        > if(parseInt(nav igator.appVersi on) >= 4)[/color]
        {
        if (win != null)
        win.focus();
        else alert("no window object");
        }
        [color=blue]
        > if (!win.opener)
        > win.opener = self;
        > }[/color]

        That would cause problems with popup blockers that killed the window.

        --
        --
        ~kaeli~
        A little rudeness and disrespect can elevate a meaningless
        interaction to a battle of wills and add drama to an
        otherwise dull day.



        Comment

        • DU

          #5
          Re: Can someone help e debug this popup window script please?

          Don wrote:[color=blue]
          > Hi,
          >
          > I have the following script that displays a popup window centered in the
          > middle of the screen. I am getting a script error in both IE and Netscape
          > but I don't know what it means. Thanks in advance.
          >
          > The error is
          > ------------
          > Error: win has no properties
          > Line 13 below ( win.window.focu s(); )
          >[/color]

          This message might refer to an asynchronuous state of the window and its
          object reference. The win variable might not be created in the stack
          while you're trying to access its properties.
          [color=blue]
          > The code is
          > ------------
          > var win= null;
          > function newWindow(mypag e,myname,w,h,sc roll) {
          > var winl = (screen.availWi dth-w)/2;
          > var wint = (screen.availHe ight-h)/2;
          > var settings ='height='+h+', ';
          > settings +='width='+w+', ';
          > settings +='top='+wint+' ,';
          > settings +='left='+winl+ ',';
          > settings +='scrollbars=' +scroll+',';
          > settings +='resizable=ye s';[/color]

          Scrollbars should be set to true (or 1) at all the time: scrollbar(s)
          should appear when content overflows requested window dimensions,
          otherwise the popup goes against normal and standard accessibility to
          content.
          [color=blue]
          > win=window.open (mypage,myname, settings);
          > if(parseInt(nav igator.appVersi on) >= 4)
          > win.window.focu s();[/color]

          There is no point to this instruction. You are supposed to just have
          created and opened a new window which will be brought on top of the
          opener. Why try to bring it on top? This is redundant and unneeded.
          [color=blue]
          > if (!win.opener)
          > win.opener = self;[/color]

          This instruction too should be dropped. It can only lead to problems.

          DU

          Comment

          • DU

            #6
            Re: Can someone help e debug this popup window script please?

            kaeli wrote:

            [color=blue][color=green]
            >>
            >>The error is
            >>------------
            >>Error: win has no properties
            >>Line 13 below ( win.window.focu s(); )[/color]
            >
            >
            > win is a window object. There is no window property of a window object,
            > AFAIK.
            >[/color]

            "The window property is a synonym for the current window or frame.
            Property of window
            Read-only (...)"


            DU

            Comment

            • kaeli

              #7
              Re: Can someone help e debug this popup window script please?

              In article <bujnuc$7lr$1@n ews.eusc.inter. net>,
              drunclear@hotWI PETHISmail.com enlightened us with...[color=blue]
              >
              > "The window property is a synonym for the current window or frame.
              > Property of window
              > Read-only (...)"
              > http://devedge.netscape.com/library/...w.html#1204007
              >[/color]

              Good to know.

              Thanks!


              --
              --
              ~kaeli~
              Dijon vu - the same mustard as before.



              Comment

              Working...