window.open, target=_blank opens two windows

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

    window.open, target=_blank opens two windows

    The code:
    <a href="/art/visit/openhouse03/images/17.jpg" target="_blank"
    onclick="popCen ter(this.href,' name','500','50 0','no'); return false;">
    <img src="/art/visit/openhouse03/images/thumb17.jpg"></a>

    The problem:
    I always get two windows. I have the required "return false". I found a
    post (http://tinyurl.com/avjlh) that addresses my exact problem, but
    they told the guy he wasn't returning false properly. That doesn't make
    any sense.

    I could hack it by targeting the same window that JS opens, but then
    I'm loading the page twice.

    I just want it call my function if the user has JS, and open a blank
    window if they don't.

    Thanks.

    --Don D.
    (not the same Don as in the link given above)

  • RobG

    #2
    Re: window.open, target=_blank opens two windows

    DonD wrote:[color=blue]
    > The code:
    > <a href="/art/visit/openhouse03/images/17.jpg" target="_blank"
    > onclick="popCen ter(this.href,' name','500','50 0','no'); return false;">
    > <img src="/art/visit/openhouse03/images/thumb17.jpg"></a>
    >
    > The problem:
    > I always get two windows. I have the required "return false". I found a
    > post (http://tinyurl.com/avjlh) that addresses my exact problem, but
    > they told the guy he wasn't returning false properly. That doesn't make
    > any sense.
    >
    > I could hack it by targeting the same window that JS opens, but then
    > I'm loading the page twice.
    >
    > I just want it call my function if the user has JS, and open a blank
    > window if they don't.[/color]

    I suspect something funny is happening in your popCenter() script. Try
    the following:

    <script type="text/javascript">
    function popCenter( url, n, a, b, c ){
    aWin = window.open( url, n, '');
    }
    </script>

    <a href="a.gif" target="_blank" onclick="
    popCenter(this. href,'name','50 0','500','no'); return false;
    "><img src="a.gif"></a>


    I can only test in IE with JavaScript on, but it worked fine in Firefox
    with scripting on or off.



    --
    Rob

    Comment

    • Phat G5 (G3)

      #3
      Re: window.open, target=_blank opens two windows

      in article 1123030690.0642 32.36150@g44g20 00...legro ups.com, DonD at
      Don.Douthitt@gm ail.com wrote on 8/2/05 5:58 PM:
      [color=blue]
      > The code:
      > <a href="/art/visit/openhouse03/images/17.jpg" target="_blank"
      > onclick="popCen ter(this.href,' name','500','50 0','no'); return false;">
      > <img src="/art/visit/openhouse03/images/thumb17.jpg"></a>
      >
      > The problem:
      > I always get two windows. I have the required "return false". I found a
      > post (http://tinyurl.com/avjlh) that addresses my exact problem, but
      > they told the guy he wasn't returning false properly. That doesn't make
      > any sense.
      >
      > I could hack it by targeting the same window that JS opens, but then
      > I'm loading the page twice.
      >
      > I just want it call my function if the user has JS, and open a blank
      > window if they don't.
      >
      > Thanks.
      >
      > --Don D.
      > (not the same Don as in the link given above)
      >[/color]
      Don, get rid of the target="_blank" that is not needed. The javascript
      function is separate of the html function target and that is why you are
      seeing that happening.

      Comment

      • DonD

        #4
        Re: window.open, target=_blank opens two windows

        Phat G5(G3),

        I'm not sure I understand. If the user has JS turned off, I still want
        them to get a new window. I don't want the larger image to load in the
        same window. If the user does have JS, then they get my window with the
        proper sizing, etc. I can't give non-JS users a new window without
        target=_blank, can I? I don't know a way.

        --Don D.

        Comment

        • ??

          #5
          Re: window.open, target=_blank opens two windows

          Then why dun u just leave the JS and use HTML on its own.


          mo


          "DonD" <Don.Douthitt@g mail.com> wrote in message
          news:1123069382 .363650.289120@ g43g2000cwa.goo glegroups.com.. .[color=blue]
          > Phat G5(G3),
          >
          > I'm not sure I understand. If the user has JS turned off, I still want
          > them to get a new window. I don't want the larger image to load in the
          > same window. If the user does have JS, then they get my window with the
          > proper sizing, etc. I can't give non-JS users a new window without
          > target=_blank, can I? I don't know a way.
          >
          > --Don D.
          >[/color]


          Comment

          • Kevin Newman

            #6
            Re: window.open, target=_blank opens two windows

            ?? wrote:[color=blue]
            > Then why dun u just leave the JS and use HTML on its own.[/color]


            Because you can customize the popup in javascript in a way that you
            cannot in html. Doing it this way means it will "gracefully degrade" if
            javascript is turned off, but that you will get all the benefits if it
            is on.

            Kevin N.

            Comment

            • DonD

              #7
              Re: window.open, target=_blank opens two windows

              RobG,

              You're exactly right. I was calling another function within popCenter
              and it was opening the additional window. I was digging in the wrong
              place. Thanks!

              --Don D.

              Comment

              • Phat G5 (G3)

                #8
                Re: window.open, target=_blank opens two windows

                in article 1123069382.3636 50.289120@g43g2 00...legr oups.com, DonD at
                Don.Douthitt@gm ail.com wrote on 8/3/05 4:43 AM:
                [color=blue]
                > Phat G5(G3),
                >
                > I'm not sure I understand. If the user has JS turned off, I still want
                > them to get a new window. I don't want the larger image to load in the
                > same window. If the user does have JS, then they get my window with the
                > proper sizing, etc. I can't give non-JS users a new window without
                > target=_blank, can I? I don't know a way.
                >
                > --Don D.
                >[/color]
                No, you cannot. Its one way or the other. The only thing I can think of is
                to write a function that will loop thru all windows looking for one with
                your url and if not found then pop a new one. It'd take some work but
                doable.

                -Steffan

                Comment

                • Phat G5 (G3)

                  #9
                  Re: window.open, target=_blank opens two windows

                  in article 42f0ca93$1@127. 0.0.1, ?? at m@m.com wrote on 8/3/05 6:47 AM:
                  [color=blue]
                  > Then why dun u just leave the JS and use HTML on its own.
                  >
                  >
                  > mo
                  >
                  >
                  > "DonD" <Don.Douthitt@g mail.com> wrote in message
                  > news:1123069382 .363650.289120@ g43g2000cwa.goo glegroups.com.. .[color=green]
                  >> Phat G5(G3),
                  >>
                  >> I'm not sure I understand. If the user has JS turned off, I still want
                  >> them to get a new window. I don't want the larger image to load in the
                  >> same window. If the user does have JS, then they get my window with the
                  >> proper sizing, etc. I can't give non-JS users a new window without
                  >> target=_blank, can I? I don't know a way.
                  >>
                  >> --Don D.
                  >>[/color]
                  >
                  >[/color]
                  Earlier in this thread he is using a JS function to pop the window centered
                  and sized.

                  Comment

                  • Joe D Williams

                    #10
                    Re: window.open, target=_blank opens two windows

                    target="_blank"

                    popCenter(this. href,'name',

                    Try lmaking the target have the same characters,
                    like:

                    target="name"


                    Joe

                    "RobG" <rgqld@iinet.ne t.auau> wrote in message
                    news:mgVHe.136$ Tg4.4835@news.o ptus.net.au...[color=blue]
                    > DonD wrote:[color=green]
                    > > The code:
                    > > <a href="/art/visit/openhouse03/images/17.jpg" target="_blank"
                    > > onclick="popCen ter(this.href,' name','500','50 0','no'); return false;">
                    > > <img src="/art/visit/openhouse03/images/thumb17.jpg"></a>
                    > >
                    > > The problem:
                    > > I always get two windows. I have the required "return false". I found a
                    > > post (http://tinyurl.com/avjlh) that addresses my exact problem, but
                    > > they told the guy he wasn't returning false properly. That doesn't make
                    > > any sense.
                    > >
                    > > I could hack it by targeting the same window that JS opens, but then
                    > > I'm loading the page twice.
                    > >
                    > > I just want it call my function if the user has JS, and open a blank
                    > > window if they don't.[/color]
                    >
                    > I suspect something funny is happening in your popCenter() script. Try
                    > the following:
                    >
                    > <script type="text/javascript">
                    > function popCenter( url, n, a, b, c ){
                    > aWin = window.open( url, n, '');
                    > }
                    > </script>
                    >
                    > <a href="a.gif" target="_blank" onclick="
                    > popCenter(this. href,'name','50 0','500','no'); return false;
                    > "><img src="a.gif"></a>
                    >
                    >
                    > I can only test in IE with JavaScript on, but it worked fine in Firefox
                    > with scripting on or off.
                    >
                    >
                    >
                    > --
                    > Rob[/color]


                    Comment

                    Working...