window.open() opens two windows

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

    window.open() opens two windows

    Problem:
    using a named window as target, a new window is opened anyway. Also, both
    windows have the same name. This happens on SOME machines only

    env:
    XP sp2
    ie6.0.2900.2180
    + sp2

    Replicate with these two files, "test1.html "

    <HTML><BODY>
    <script>
    function openit(){
    var addlookup=open( 'about:blank',' addlookup');
    document.f1.tar get="addlookup" ;
    document.f1.sub mit();
    }
    </script>

    <form name=f1 action="test2.h tml" >
    <input type=button onclick="openit ();" value="open">
    </form>

    </BODY></HTML>

    .... and "test2.html "

    <HTML><BODY>
    <script>
    function showname(){
    alert(self.name );
    }
    </script>
    </HEAD>
    <BODY>
    Click this is to see window name <input type=button onclick="showna me();">
    </BODY>
    </HTML>

    --------

    if you use
    var addlookup=open( 'test2.html','a ddlookup');
    then you can see the same name being used twice.

    We've had this problem on a few machines here (about 3 out of 20), which all
    appear to have identical explorer settings.
    A few posts here seem to have the same problem but no follow ups have
    helped.

    Hope someone can help.
    Mike
  • Lee

    #2
    Re: window.open() opens two windows

    MPH said:[color=blue]
    >
    >Problem:
    >using a named window as target, a new window is opened anyway. Also, both
    >windows have the same name. This happens on SOME machines only[/color]
    [color=blue]
    ><script>
    >function openit(){
    >var addlookup=open( 'about:blank',' addlookup');
    > document.f1.tar get="addlookup" ;
    > document.f1.sub mit();
    >}
    ></script>[/color]

    The open() method returns immediately, without waiting for the
    windowing system to actually create the window. If that happens
    to take a little longer on some machines, the new window won't
    exist yet when you submit the form. Since no window exists by
    the name "addlookup" , a new one is created.

    setTimeout("doc ument.f1.submit ()",1000);

    Comment

    • Evertjan.

      #3
      Re: window.open() opens two windows

      Lee wrote on 28 apr 2005 in comp.lang.javas cript:[color=blue]
      > MPH said:[color=green]
      >>
      >>Problem:
      >>using a named window as target, a new window is opened anyway. Also, both
      >>windows have the same name. This happens on SOME machines only[/color]
      >[color=green]
      >><script>
      >>function openit(){
      >>var addlookup=open( 'about:blank',' addlookup');
      >> document.f1.tar get="addlookup" ;
      >> document.f1.sub mit();
      >>}
      >></script>[/color]
      >
      > The open() method returns immediately, without waiting for the
      > windowing system to actually create the window. If that happens
      > to take a little longer on some machines, the new window won't
      > exist yet when you submit the form. Since no window exists by
      > the name "addlookup" , a new one is created.
      >
      > setTimeout("doc ument.f1.submit ()",1000);[/color]

      The same effect can be reached by just:

      <script>
      function openit(){
      document.f1.tar get="_blank";
      document.f1.sub mit();
      }
      </script>


      --
      Evertjan.
      The Netherlands.
      (Replace all crosses with dots in my emailaddress)

      Comment

      • Mike Hammett

        #4
        Re: window.open() opens two windows



        Hi Lee,

        Thanks for your quick response, however on replacing
        "document.f1.su bmit();"with "setTimeout("do cument.f1.submi t()",1000);",
        two windows are still displayed. What happens now is that the specified
        window appears straight away with no content and a full browser window
        appears with the content after the time specified in the second
        parameter of settimeout().

        Thanks

        MPH

        *** Sent via Developersdex http://www.developersdex.com ***

        Comment

        • mph

          #5
          Re: window.open() opens two windows



          Thanks Evertjan, however the problem is still the same two pop-up
          windows are still being created. This is strange as the code has worked
          correctly for the last couple of years and I have not changed the code
          at all, but since a couple of days ago I have had this problem.

          *** Sent via Developersdex http://www.developersdex.com ***

          Comment

          • Evertjan.

            #6
            Re: window.open() opens two windows

            mph wrote on 28 apr 2005 in comp.lang.javas cript:
            [color=blue]
            > Thanks Evertjan, however the problem is still the same two pop-up
            > windows are still being created. This is strange as the code has worked
            > correctly for the last couple of years and I have not changed the code
            > at all, but since a couple of days ago I have had this problem.[/color]

            Please quote, this is usenet, mnot email.
            [color=blue]
            > the problem is still[/color]

            impossible with my code, please try again.

            --
            Evertjan.
            The Netherlands.
            (Replace all crosses with dots in my emailaddress)

            Comment

            • MPH

              #7
              Re: window.open() opens two windows


              Evertjan. wrote:[color=blue]
              > mph wrote on 28 apr 2005 in comp.lang.javas cript:
              >[color=green]
              > > Thanks Evertjan, however the problem is still the same two pop-up
              > > windows are still being created. This is strange as the code has[/color][/color]
              worked[color=blue][color=green]
              > > correctly for the last couple of years and I have not changed the[/color][/color]
              code[color=blue][color=green]
              > > at all, but since a couple of days ago I have had this problem.[/color]
              >
              > Please quote, this is usenet, mnot email.
              >[color=green]
              > > the problem is still[/color]
              >
              > impossible with my code, please try again.
              >
              > --
              > Evertjan.
              > The Netherlands.
              > (Replace all crosses with dots in my emailaddress)[/color]


              My apologies Evertjan, as you rightly point out the code suggested by
              yourself does only create the one required window. However I need to
              use window.open() as this will allow me to determine the attributes of
              the new window, it will also give me a window handle which I can use to
              close the window elsewhere in my code.
              Are you aware of a way that I may be able to achieve this?

              Thanks

              Comment

              • Evertjan.

                #8
                Re: window.open() opens two windows

                MPH wrote on 29 apr 2005 in comp.lang.javas cript:
                [color=blue]
                >
                > Evertjan. wrote:[color=green]
                >> mph wrote on 28 apr 2005 in comp.lang.javas cript:
                >>[color=darkred]
                >> > Thanks Evertjan, however the problem is still the same two pop-up
                >> > windows are still being created. This is strange as the code has[/color][/color]
                > worked[color=green][color=darkred]
                >> > correctly for the last couple of years and I have not changed the[/color][/color]
                > code[color=green][color=darkred]
                >> > at all, but since a couple of days ago I have had this problem.[/color]
                >>
                >> Please quote, this is usenet, mnot email.
                >>[color=darkred]
                >> > the problem is still[/color]
                >>
                >> impossible with my code, please try again.
                >>
                >> --
                >> Evertjan.
                >> The Netherlands.
                >> (Replace all crosses with dots in my emailaddress)[/color]
                >
                >
                > My apologies Evertjan, as you rightly point out the code suggested by
                > yourself does only create the one required window. However I need to
                > use window.open() as this will allow me to determine the attributes of
                > the new window, it will also give me a window handle which I can use to
                > close the window elsewhere in my code.
                > Are you aware of a way that I may be able to achieve this?[/color]

                I don't think you can submit to 'about:blank'

                But try this, works fine here:

                ========== test.html ===============

                <script type='text/javascript'>
                var addlookup=open( '','blah');

                function openit(){
                setTimeout('sub mitIt()',1000)
                }

                function submitIt(){
                document.forms. f1.submit();
                }

                openit()
                </script>

                <form name=f1 target='blah' action='test2.h tml'>
                <input name=a value=b>
                </form>





                --
                Evertjan.
                The Netherlands.
                (Replace all crosses with dots in my emailaddress)

                Comment

                • MPH

                  #9
                  Re: window.open() opens two windows

                  "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message news:<Xns9647A2 3BE81A1eejj99@1 94.109.133.29>. ..[color=blue]
                  > MPH wrote on 29 apr 2005 in comp.lang.javas cript:
                  >[color=green]
                  > >
                  > > Evertjan. wrote:[color=darkred]
                  > >> mph wrote on 28 apr 2005 in comp.lang.javas cript:
                  > >>
                  > >> > Thanks Evertjan, however the problem is still the same two pop-up
                  > >> > windows are still being created. This is strange as the code has[/color]
                  > > worked[color=darkred]
                  > >> > correctly for the last couple of years and I have not changed the[/color]
                  > > code[color=darkred]
                  > >> > at all, but since a couple of days ago I have had this problem.
                  > >>
                  > >> Please quote, this is usenet, mnot email.
                  > >>
                  > >> > the problem is still
                  > >>
                  > >> impossible with my code, please try again.
                  > >>
                  > >> --
                  > >> Evertjan.
                  > >> The Netherlands.
                  > >> (Replace all crosses with dots in my emailaddress)[/color]
                  > >
                  > >
                  > > My apologies Evertjan, as you rightly point out the code suggested by
                  > > yourself does only create the one required window. However I need to
                  > > use window.open() as this will allow me to determine the attributes of
                  > > the new window, it will also give me a window handle which I can use to
                  > > close the window elsewhere in my code.
                  > > Are you aware of a way that I may be able to achieve this?[/color]
                  >
                  > I don't think you can submit to 'about:blank'
                  >
                  > But try this, works fine here:
                  >
                  > ========== test.html ===============
                  >
                  > <script type='text/javascript'>
                  > var addlookup=open( '','blah');
                  >
                  > function openit(){
                  > setTimeout('sub mitIt()',1000)
                  > }
                  >
                  > function submitIt(){
                  > document.forms. f1.submit();
                  > }
                  >
                  > openit()
                  > </script>
                  >
                  > <form name=f1 target='blah' action='test2.h tml'>
                  > <input name=a value=b>
                  > </form>[/color]


                  Thanks for the example, yes it does work for me, but it does not give
                  me any control over when the child window is created, this is a
                  problem because of the way child windows are used on my website.

                  As mentioned before myself and others have been using the current code
                  for the last couple of years without a problem, but I can no longer
                  get the current code to work, and I have not knowingly made any
                  changes.

                  Is the behaviour shown in the code symptomatic of any obvious settings
                  in windows or IE?

                  Thanks for your help.

                  Comment

                  • Evertjan.

                    #10
                    Re: window.open() opens two windows

                    MPH wrote on 03 mei 2005 in comp.lang.javas cript:
                    [color=blue]
                    > Is the behaviour shown in the code symptomatic of any obvious settings
                    > in windows or IE?
                    >[/color]

                    I don't know. Possibly the/a popup blocker is interfering?

                    --
                    Evertjan.
                    The Netherlands.
                    (Replace all crosses with dots in my emailaddress)

                    Comment

                    • MPH

                      #11
                      Re: window.open() opens two windows


                      Evertjan. wrote:[color=blue]
                      > MPH wrote on 03 mei 2005 in comp.lang.javas cript:
                      >[color=green]
                      > > Is the behaviour shown in the code symptomatic of any obvious[/color][/color]
                      settings[color=blue][color=green]
                      > > in windows or IE?
                      > >[/color]
                      >
                      > I don't know. Possibly the/a popup blocker is interfering?
                      >
                      > --
                      > Evertjan.
                      > The Netherlands.
                      > (Replace all crosses with dots in my emailaddress)[/color]

                      This was one of the first things I looked at, all pop-up blockers are
                      inactive on my site.

                      I have checked all my Internet Explorer settings against a colleagues
                      machines that is able to run the code and there is no difference, so I
                      am really at a loss over this.

                      Comment

                      • Evertjan.

                        #12
                        Re: window.open() opens two windows

                        MPH wrote on 04 mei 2005 in comp.lang.javas cript:[color=blue]
                        > This was one of the first things I looked at, all pop-up blockers are
                        > inactive on my site.[/color]

                        Of course.

                        Popup blockers don't reside on sites, but on clientside computers.



                        --
                        Evertjan.
                        The Netherlands.
                        (Replace all crosses with dots in my emailaddress)

                        Comment

                        • MPH

                          #13
                          Re: window.open() opens two windows


                          Evertjan. wrote:[color=blue]
                          > MPH wrote on 04 mei 2005 in comp.lang.javas cript:[color=green]
                          > > This was one of the first things I looked at, all pop-up blockers[/color][/color]
                          are[color=blue][color=green]
                          > > inactive on my site.[/color]
                          >
                          > Of course.
                          >
                          > Popup blockers don't reside on sites, but on clientside computers.
                          >[/color]
                          I know, this wasnt what I meant.[color=blue]
                          >
                          >
                          > --
                          > Evertjan.
                          > The Netherlands.
                          > (Replace all crosses with dots in my emailaddress)[/color]

                          Comment

                          • Evertjan.

                            #14
                            Re: window.open() opens two windows

                            MPH wrote on 04 mei 2005 in comp.lang.javas cript:[color=blue]
                            > Evertjan. wrote:[color=green]
                            >> MPH wrote on 04 mei 2005 in comp.lang.javas cript:[color=darkred]
                            >> > This was one of the first things I looked at, all pop-up blockers[/color][/color]
                            > are[color=green][color=darkred]
                            >> > inactive on my site.[/color]
                            >>
                            >> Of course.
                            >>
                            >> Popup blockers don't reside on sites, but on clientside computers.
                            >>[/color]
                            > I know, this wasnt what I meant.[/color]

                            So I gathered, but I could not resist. ;-}

                            Terrible, isn't it|?

                            --
                            Evertjan.
                            The Netherlands.
                            (Replace all crosses with dots in my emailaddress)

                            Comment

                            Working...