Multiple Popup windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Willem van Isselmuden

    Multiple Popup windows

    Hello,

    I've a problem I hava a page with different popup windows,
    when I hit a link the first one pops up and with the first open i would like
    to hit the second link in the parent page so the second links pops up a
    window in
    the first popup. The way I have it now is working but with each link the
    size
    of the popup window should be different but that doesnt happen how can I
    solve that problem?

    this is my code:

    function NewWindow(mypag e, myname, w, h, scroll) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    winprops =
    'height='+h+',w idth='+w+',top= '+wint+',left=' +winl+',scrollb ars='+scroll+', r
    esizable'
    win = window.open(myp age, myname, winprops)
    if (parseInt(navig ator.appVersion ) >= 4) { win.window.focu s(); }
    }


    the first link:
    <a href="#"
    onClick="NewWin dow('info_banke tquiz.html','na me','488','255' );return
    false;">info</a>


    the second link:
    <a href="#"
    onClick="NewWin dow('info_consu menten.html','n ame','488','405 ');return
    false;">info</a>


    I hope that somebody can help me

    Greetings Willem


  • Lasse Reichstein Nielsen

    #2
    Re: Multiple Popup windows

    "Willem van Isselmuden" <isselmuden@hot mail.com> writes:
    [color=blue]
    > the first popup. The way I have it now is working but with each link
    > the size of the popup window should be different but that doesnt
    > happen
    > how can I solve that problem?[/color]
    [color=blue]
    > function NewWindow(mypag e, myname, w, h, scroll) {
    > var winl = (screen.width - w) / 2;
    > var wint = (screen.height - h) / 2;[/color]

    It is safer not to position the new window. Positioning a window
    realtive to the screen gives trouble for MDI browsers (like Opera) and
    multi monitor setups. Letting the browser place the window will
    most likely give an acceptable result for everybody.

    Remember to make windows resizable and/or allow scrollbars. No matter
    what you might think you are prepared for, there will always be some
    person with a setup that makes the content overflow. (Me, e.g., as I
    have a user stylesheet that adds content after links with a target
    attribute, and a rule that locks the font-size of the body document to
    100%).
    [color=blue]
    > the first link:
    > <a href="#"
    > onClick="NewWin dow('info_banke tquiz.html','na me','488','255' );return
    > false;">info</a>
    >
    >
    > the second link:
    > <a href="#"
    > onClick="NewWin dow('info_consu menten.html','n ame','488','405 ');return
    > false;">info</a>[/color]

    You open both windows with the same name (in fact the name "name").
    That means that the second call to window.open will reuse the window,
    and the configuration options are ignored.

    You will either have to close the window and open it again, or just
    resize it directly (with either the .resizeTo or the .resizeBy method).
    Be aware that the resizeXX methods set the outer size of the window,
    while the window.open configuration string sets the inner width and
    height.
    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Greg

      #3
      Re: Multiple Popup windows

      "Willem van Isselmuden" <isselmuden@hot mail.com> wrote in message news:<bj2og4$bs a$1@news2.tilbu 1.nb.home.nl>.. .[color=blue]
      > Hello,
      >
      > I've a problem I hava a page with different popup windows,
      > when I hit a link the first one pops up and with the first open i would like
      > to hit the second link in the parent page so the second links pops up a
      > window in
      > the first popup. The way I have it now is working but with each link the
      > size
      > of the popup window should be different but that doesnt happen how can I
      > solve that problem?
      >
      > this is my code:
      >
      > function NewWindow(mypag e, myname, w, h, scroll) {
      > var winl = (screen.width - w) / 2;
      > var wint = (screen.height - h) / 2;
      > winprops =
      > 'height='+h+',w idth='+w+',top= '+wint+',left=' +winl+',scrollb ars='+scroll+', r
      > esizable'
      > win = window.open(myp age, myname, winprops)
      > if (parseInt(navig ator.appVersion ) >= 4) { win.window.focu s(); }
      > }
      >
      >
      > the first link:
      > <a href="#"
      > onClick="NewWin dow('info_banke tquiz.html','na me','488','255' );return
      > false;">info</a>
      >
      >
      > the second link:
      > <a href="#"
      > onClick="NewWin dow('info_consu menten.html','n ame','488','405 ');return
      > false;">info</a>
      >
      >
      > I hope that somebody can help me
      >
      > Greetings Willem[/color]

      Not a solution, but you could close the first pop up before opening
      the second, as

      <script type='text/javascript'>
      var win;
      function NewWindow(mypag e, myname, w, h, scroll) {
      var winl = (screen.width - w) / 2;
      var wint = (screen.height - h) / 2;
      var winprops = 'height=' + h + ',width=' + w + ',top=' +
      wint + ',left=' + winl + ',scrollbars=' + scroll
      + ',resizable';
      if(win)
      win.close();
      win = window.open(myp age, myname, winprops);
      if (parseInt(navig ator.appVersion ) >= 4) { win.window.focu s(); }
      }

      </script>


      <a href="#" onClick="NewWin dow('info1.htm' ,'name','488',' 255');return
      false;">info</a>
      <br>
      <a href="#" onClick="NewWin dow('info2.htm' ,'name','488',' 405'); return
      false;">info2</a>

      Comment

      • DU

        #4
        Re: Multiple Popup windows

        Greg wrote:
        [color=blue]
        > "Willem van Isselmuden" <isselmuden@hot mail.com> wrote in message news:<bj2og4$bs a$1@news2.tilbu 1.nb.home.nl>.. .
        >[color=green]
        >>Hello,
        >>
        >>I've a problem I hava a page with different popup windows,
        >>when I hit a link the first one pops up and with the first open i would like
        >>to hit the second link in the parent page so the second links pops up a
        >>window in
        >>the first popup. The way I have it now is working but with each link the
        >>size
        >>of the popup window should be different but that doesnt happen how can I
        >>solve that problem?
        >>
        >>this is my code:
        >>
        >>function NewWindow(mypag e, myname, w, h, scroll) {
        >>var winl = (screen.width - w) / 2;
        >>var wint = (screen.height - h) / 2;
        >>winprops =
        >>'height='+h+' ,width='+w+',to p='+wint+',left ='+winl+',scrol lbars='+scroll+ ',r
        >>esizable'
        >>win = window.open(myp age, myname, winprops)
        >>if (parseInt(navig ator.appVersion ) >= 4) { win.window.focu s(); }
        >>}
        >>
        >>
        >>the first link:
        >> <a href="#"
        >>onClick="NewW indow('info_ban ketquiz.html',' name','488','25 5');return
        >>false;">inf o</a>
        >>
        >>
        >>the second link:
        >> <a href="#"
        >>onClick="NewW indow('info_con sumenten.html', 'name','488','4 05');return
        >>false;">inf o</a>
        >>
        >>
        >>I hope that somebody can help me
        >>
        >>Greetings Willem[/color]
        >
        >
        > Not a solution, but you could close the first pop up before opening
        > the second,[/color]

        [snipped]

        But then you would not use efficiently the user's system resources. Why
        not simply load a different url into an already created and opened popup?

        If the window object reference exists and is opened and if the url is
        different, then load the new url into the existing popup. This is what I
        do in several of my pages.

        DU
        --
        Javascript and Browser bugs:

        - Resources, help and tips for Netscape 7.x users and Composer
        - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x


        Comment

        • DU

          #5
          Re: Multiple Popup windows

          Willem van Isselmuden wrote:
          [color=blue]
          > Hello,
          >
          > I've a problem I hava a page with different popup windows,
          > when I hit a link the first one pops up and with the first open i would like
          > to hit the second link in the parent page so the second links pops up a
          > window in
          > the first popup. The way I have it now is working but with each link the
          > size
          > of the popup window should be different but that doesnt happen how can I
          > solve that problem?
          >
          > this is my code:
          >
          > function NewWindow(mypag e, myname, w, h, scroll) {
          > var winl = (screen.width - w) / 2;
          > var wint = (screen.height - h) / 2;
          > winprops =
          > 'height='+h+',w idth='+w+',top= '+wint+',left=' +winl+',scrollb ars='+scroll+', r
          > esizable'
          > win = window.open(myp age, myname, winprops)
          > if (parseInt(navig ator.appVersion ) >= 4) { win.window.focu s(); }
          > }
          >[/color]

          This is a popular script function and a bad one.

          It should be rather
          var winl = Math.round((scr een.availWidth - w) / 2);
          var wint = Math.round((scr een.availHeight - h) / 2);

          winprops =

          'height='+h+',w idth='+w+',top= '+wint+',left=' +winl+',scrollb ars='+scroll+', r
          esizable'

          If mypage is a referenced image, then the height and width of the window
          can not be the height and width of the image because all browsers have
          default css values for margin or padding on the body element, the
          largest ones (margin:15px 10px;) being those of MSIE 5+. I mention this
          because this script is a popular one and people copy it often without
          knowing details like that.

          Allowing the script to turn off scrollbars is anti-usability and
          anti-accessibility. With "scrollbars=yes ", scrollbar(s) will appear only
          if content overflows window's dimensions: so, why would you want to turn
          off scrollbar(s) if your window needs them, if scrollbars are needed?
          After a first mistake - content might overflow window dimensions -, the
          popup definitively could need scrollbars. In case of doubt (say, user
          uses large font size), then it is always safer to allow scrollbar(s) to
          appear if they are needed. Even if you could know in advance if the
          font-size makes the content fits perfectly in the window, increasing
          font later might prevent scrollbars from appearing. This is an important
          detail if the popup can lead to other referenced resources.

          win = window.open(myp age, myname, winprops)

          The window object reference needs to be declared as a global variable,
          preferably not in the function body.

          if (parseInt(navig ator.appVersion ) >= 4) { win.window.focu s(); }

          I do not understand this line at all. If you just created a window, then
          you don't need to give it focus, obviously. In any case, checking the
          appVersion is not reliable... whatever what was the intent behind this.

          [color=blue]
          >
          > the first link:
          > <a href="#"
          > onClick="NewWin dow('info_banke tquiz.html','na me','488','255' );return
          > false;">info</a>[/color]

          There is no 5th argument. So, info_banketquiz .html will not be a
          scrollable window if content overflows window's dimensions: this is not
          recommendable. Also, if the window dimensions do not consider margin
          (padding:8px in Opera 7) on the body element, then the content might
          overflow requested dimensions... which happens often. Almost all
          dynamicdrive.co m scripts about popups or involving popups have such
          oversight and such problem.

          If javascript is disabled, then the resource is not accessible at all
          .... when it should still be accessible.

          <a href="info_bank etquiz.html" target="name"
          onClick="NewWin dow(this.href, this.target,'48 8','255');retur n
          false;">info</a>

          would correct this though.
          [color=blue]
          >
          >
          > the second link:
          > <a href="#"
          > onClick="NewWin dow('info_consu menten.html','n ame','488','405 ');return
          > false;">info</a>
          >
          >
          > I hope that somebody can help me
          >
          > Greetings Willem
          >
          >[/color]

          Go to this page



          and examine the function OpenRequestedPo pup(strUrl)

          DU
          --
          Javascript and Browser bugs:

          - Resources, help and tips for Netscape 7.x users and Composer
          - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x


          Comment

          • DU

            #6
            Re: Multiple Popup windows

            DU wrote:
            [color=blue]
            > Greg wrote:
            >[color=green]
            >> "Willem van Isselmuden" <isselmuden@hot mail.com> wrote in message
            >> news:<bj2og4$bs a$1@news2.tilbu 1.nb.home.nl>.. .
            >>[color=darkred]
            >>> Hello,
            >>>
            >>> I've a problem I hava a page with different popup windows,
            >>> when I hit a link the first one pops up and with the first open i
            >>> would like
            >>> to hit the second link in the parent page so the second links pops up a
            >>> window in
            >>> the first popup. The way I have it now is working but with each link the
            >>> size
            >>> of the popup window should be different but that doesnt happen how can I
            >>> solve that problem?
            >>>
            >>> this is my code:
            >>>
            >>> function NewWindow(mypag e, myname, w, h, scroll) {
            >>> var winl = (screen.width - w) / 2;
            >>> var wint = (screen.height - h) / 2;
            >>> winprops =
            >>> 'height='+h+',w idth='+w+',top= '+wint+',left=' +winl+',scrollb ars='+scroll+', r
            >>>
            >>> esizable'
            >>> win = window.open(myp age, myname, winprops)
            >>> if (parseInt(navig ator.appVersion ) >= 4) { win.window.focu s(); }
            >>> }
            >>>
            >>>
            >>> the first link:
            >>> <a href="#"
            >>> onClick="NewWin dow('info_banke tquiz.html','na me','488','255' );return
            >>> false;">info</a>
            >>>
            >>>
            >>> the second link:
            >>> <a href="#"
            >>> onClick="NewWin dow('info_consu menten.html','n ame','488','405 ');return
            >>> false;">info</a>
            >>>
            >>>
            >>> I hope that somebody can help me
            >>>
            >>> Greetings Willem[/color]
            >>
            >>
            >>
            >> Not a solution, but you could close the first pop up before opening
            >> the second,[/color]
            >
            >
            > [snipped]
            >
            > But then you would not use efficiently the user's system resources. Why
            > not simply load a different url into an already created and opened popup?
            >
            > If the window object reference exists and is opened and if the url is
            > different, then load the new url into the existing popup. This is what I
            > do in several of my pages.
            >[/color]

            ....unless the requested window toolbars, requested window dimensions,
            etc... are different... which is the case here in the given code as both
            popups have different heights.

            DU
            --
            Javascript and Browser bugs:

            - Resources, help and tips for Netscape 7.x users and Composer
            - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x


            Comment

            Working...