dynamic popup

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

    #1

    dynamic popup

    Hi,
    I have two buttons calling the same funtion to open a popup window,
    dinamically built according to parameters passed to the function.

    The problem: when I click the first button (or the second), anything
    goes. When I call the function again /that is, from the athor button), I
    get no window subtitution: that is, the second popup loads into the
    first, loosing w and h too...

    I simply need this substitution: is this possible?

    Thanks to everybody in advance, PM



    ---

    <script>
    function openPop(url, nome, w, h, pD, tD) {
    var features = "";
    features += "scrollbars=no, ";
    features += "menubar=no ,";
    features += "resizable=no," ;
    features += "left="+Math.fl oor(screen.widt h/2-w/2)+",";
    features += "top="+Math.flo or(screen.heigh t/2-h/2)+",";
    features += "alwaysRaised=y es,";
    features += "width=" + w + ",";
    features += "height=" + h;
    nw = window.open(url , nome, features);
    nw.document.ope n();
    nw.document.wri te("<html>");
    nw.document.wri te("<head>");
    nw.document.wri te("<title>"+tD +"</title>");
    nw.document.wri te("</head>");
    nw.document.wri te("<body leftmargin='0' topmargin='0' marginwidth='0'
    marginheight='0 '>");
    nw.document.wri te("<img src="+pD+" width="+w+" height="+h+" title="+tD+">") ;
    nw.document.wri te("</body>");
    nw.document.wri te("</html>");
    nw.document.clo se()
    }

    </script>


    <a
    href="javascrip t:openPop('popu p.htm','des','4 99','610','dese rt.jpg','desert ')">b1</a>
    <a
    href="javascrip t:openPop('popu p.htm','tus','3 30','630','cact us.jpg','cactus ')">b2</a>
  • RobB

    #2
    Re: dynamic popup

    playmaker wrote:[color=blue]
    > Hi,
    > I have two buttons calling the same funtion to open a popup window,
    > dinamically built according to parameters passed to the function.
    >
    > The problem: when I click the first button (or the second), anything
    > goes. When I call the function again /that is, from the athor[/color]
    button), I[color=blue]
    > get no window subtitution: that is, the second popup loads into the
    > first, loosing w and h too...
    >
    > I simply need this substitution: is this possible?
    >
    > Thanks to everybody in advance, PM
    >
    >
    >
    > ---
    >
    > <script>
    > function openPop(url, nome, w, h, pD, tD) {
    > var features = "";
    > features += "scrollbars=no, ";
    > features += "menubar=no ,";
    > features += "resizable=no," ;
    > features += "left="+Math.fl oor(screen.widt h/2-w/2)+",";
    > features += "top="+Math.flo or(screen.heigh t/2-h/2)+",";
    > features += "alwaysRaised=y es,";
    > features += "width=" + w + ",";
    > features += "height=" + h;
    > nw = window.open(url , nome, features);
    > nw.document.ope n();
    > nw.document.wri te("<html>");
    > nw.document.wri te("<head>");
    > nw.document.wri te("<title>"+tD +"</title>");
    > nw.document.wri te("</head>");
    > nw.document.wri te("<body leftmargin='0' topmargin='0' marginwidth='0'[/color]
    [color=blue]
    > marginheight='0 '>");
    > nw.document.wri te("<img src="+pD+" width="+w+" height="+h+"[/color]
    title="+tD+">") ;[color=blue]
    > nw.document.wri te("</body>");
    > nw.document.wri te("</html>");
    > nw.document.clo se()
    > }
    >
    > </script>
    >
    >
    > <a
    >[/color]
    href="javascrip t:openPop('popu p.htm','des','4 99','610','dese rt.jpg','desert ')">b1</a>[color=blue]
    > <a
    >[/color]
    href="javascrip t:openPop('popu p.htm','tus','3 30','630','cact us.jpg','cactus ')">b2</a>

    Not precisely sure what the problem is - the usual culprit is use of
    the same name for both windows, but you didn't do that. In any event,
    that script has whiskers on it, along with some oddities
    ('alwaysRaised' only works with signed scripts, e.g.), and the code is
    about as inefficient as possible. Nothing for the JS-disabled either.
    Try this:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>untitled </title>
    <script type="text/javascript">

    function openPop(pD, nome, w, h, tD)
    {
    var features = [
    'scrollbars=no' ,
    'menubar=no' ,
    'resizable=no' ,
    'left='+Math.fl oor(screen.widt h/2-w/2) ,
    'top='+Math.flo or(screen.heigh t/2-h/2) ,
    'width=' + w,
    'height=' + h
    ].join(',');
    HTML = [
    '<html>' ,
    '<head>' ,
    '<title>'+tD+' </title>' ,
    '</head>' ,
    '<body style="margin:0 ;">' ,
    '<img src="'+pD+'" width="'+w+'" height="'+h+'" title="'+tD+'"> ' ,
    '</body>' ,
    '</html>'
    ].join('');
    nw = window.open('ja vascript:opener .HTML', nome, features);
    if (nw && !nw.closed && nw.focus)
    nw.focus();
    return false;
    }

    </script>
    </head>
    <body>
    <a href="desert.jp g" onclick="return
    openPop(this.hr ef,'des','499', '610','desert') ">b1</a>
    <a href="cactus.jp g" onclick="return
    openPop(this.hr ef,'tus','330', '630','cactus') ">b2</a>
    </body>
    </html>

    Don't use pop-ups, blah blah blah...I'll spare you the lecture.

    Comment

    • playmaker

      #3
      Re: dynamic popup

      Hi,
      first of all thanks.

      Second: I'm sorry for the oddities but it is my first js function ever,
      so excuse me...

      And... I gave you the code to call a function from html but I forgot to
      say that I'm calling the function from Flash this way:

      on (release) {
      u = "popup.htm" ;
      n = 'nnn';
      ww = 450;
      hh = 560;
      img = 'cactus.jpg';
      tt = 'Titletitle';

      getURL("javascr ipt:openPop("+" '"+u+"'"+','+"' "+n+"'"+','+"'" +ww+"'"+','+"'" +hh+"'"+','+"'" +img+"'"+','+"' "+tt+"'"+") ");
      }

      I receive the values of those vars (u, n, ww etc.) from PHP/MySQL and I
      use them to open popups. Why popups? Simple: it is the site of a visual
      artist (a painter) and the substance of the site is his work (I put 10
      thumbnails for page and I click on them to open the popups). The idea of
      using one single popup is to avoid that one user opens 10 popup at the
      same time... So I had to "mediate" a solution...

      Thanks for the cose, now I must understand how use it from the swf file.

      best regards,
      PM

      Comment

      • playmaker

        #4
        Re: dynamic popup

        Hi,
        I tryed you code "as is" (without Flash)
        but is doesn't work (IE 6, Firefox 1)... I can't understand why...

        PM

        Comment

        • RobB

          #5
          Re: dynamic popup

          If there's a line break after 'return' (in the link),
          remove it.

          Should be easy enough to modify...no need to pass a url, since you're
          just generating a new document anyway; the only url you need is
          that of the pic. I prefer loading a window with a favelet (javascript:)
          over
          the usual document.writes . (Much) less likely to encounter timing
          problems
          that way.

          Take a look at some of the slide shows at



          Imaginative, and done within the same window, avoiding blocker problems

          and the like.

          Comment

          • playmaker

            #6
            Re: dynamic popup

            everything is very beautyful there... :-)

            Anyway, the code (don't know why) it is not working:
            it opens a page as it was open using "_blank" and display the image in
            the page: every toolbar is there, so any other attrubute... It IS a new
            page, not a popup and I can't see the source ("html" is grayed)...

            Thanks, PM

            Comment

            • RobB

              #7
              Re: dynamic popup

              This must be on one line:

              <a href="desert.jp g" onclick="return
              openPop(this.hr ef,'des','499', '610','desert') ">b1</a>

              Remove any carriage returns.

              Comment

              • playmaker

                #8
                Re: dynamic popup

                fantastic...
                Only one thing: on IE6 I get a little white space under the image (3 or
                4 pixel): is there any way to eliminate it?

                Thanks, PM

                Comment

                • RobB

                  #9
                  Re: dynamic popup

                  playmaker wrote:[color=blue]
                  > fantastic...
                  > Only one thing: on IE6 I get a little white space under the image (3[/color]
                  or[color=blue]
                  > 4 pixel): is there any way to eliminate it?
                  >
                  > Thanks, PM[/color]

                  Try modifying these lines:

                  '<body style="margin:0 ;background:bla ck;">' ,
                  '<img src="'+pD+'" width="'+w+'" height="'+h+'" title="'+tD+'"
                  border="0">' ,

                  (each one on ONE line only)...make sure you've got the image dimensions
                  correct.

                  Comment

                  • playmaker

                    #10
                    Re: dynamic popup

                    Hi, I tried but it's the same:
                    the features are correct (w and h):
                    the problem is only for IE6/XP/SP2... :-(

                    PM



                    RobB wrote:[color=blue]
                    > playmaker wrote:
                    >[color=green]
                    >>fantastic.. .
                    >>Only one thing: on IE6 I get a little white space under the image (3[/color]
                    >
                    > or
                    >[color=green]
                    >>4 pixel): is there any way to eliminate it?
                    >>
                    >>Thanks, PM[/color]
                    >
                    >
                    > Try modifying these lines:
                    >
                    > '<body style="margin:0 ;background:bla ck;">' ,
                    > '<img src="'+pD+'" width="'+w+'" height="'+h+'" title="'+tD+'"
                    > border="0">' ,
                    >
                    > (each one on ONE line only)...make sure you've got the image dimensions
                    > correct.
                    >[/color]

                    Comment

                    • RobB

                      #11
                      Re: dynamic popup

                      playmaker wrote:[color=blue]
                      > Hi, I tried but it's the same:
                      > the features are correct (w and h):
                      > the problem is only for IE6/XP/SP2... :-(
                      >
                      > PM
                      >
                      >
                      >
                      > RobB wrote:[color=green]
                      > > playmaker wrote:
                      > >[color=darkred]
                      > >>fantastic.. .
                      > >>Only one thing: on IE6 I get a little white space under the image[/color][/color][/color]
                      (3[color=blue][color=green]
                      > >
                      > > or
                      > >[color=darkred]
                      > >>4 pixel): is there any way to eliminate it?
                      > >>
                      > >>Thanks, PM[/color]
                      > >
                      > >
                      > > Try modifying these lines:
                      > >
                      > > '<body style="margin:0 ;background:bla ck;">' ,
                      > > '<img src="'+pD+'" width="'+w+'" height="'+h+'" title="'+tD+'"
                      > > border="0">' ,
                      > >
                      > > (each one on ONE line only)...make sure you've got the image[/color][/color]
                      dimensions[color=blue][color=green]
                      > > correct.
                      > >[/color][/color]

                      Looks OK here. Try substituting:

                      ...............
                      ...............
                      HTML = [
                      '<html>' ,
                      '<head>' ,
                      '<title>'+tD+' </title>' ,
                      '</head>' ,
                      '<body style="margin:0 ;background:bla ck;">' ,
                      '<img style="border-width:0;" src="'+pD+'" title="'+tD+'"> ' ,
                      '</body>' ,
                      '</html>'
                      ].join('');
                      nw = window.open('ja vascript:opener .HTML', nome, features);
                      if (nw && !nw.closed && nw.focus)
                      nw.focus();
                      return false;
                      }

                      Make sure the image size is accurate. Images will resize in the browser
                      if the dimensions are set in HTML/CSS so, don't trust those properties.
                      Open the image (url) in its own window, or in your image editor.

                      Comment

                      • playmaker

                        #12
                        Re: dynamic popup

                        RobB wrote:[color=blue]
                        > playmaker wrote:
                        >[color=green]
                        >>Hi, I tried but it's the same:
                        >>the features are correct (w and h):
                        >>the problem is only for IE6/XP/SP2... :-(
                        >>
                        >>PM
                        >>
                        >>
                        >>
                        >>RobB wrote:
                        >>[color=darkred]
                        >>>playmaker wrote:
                        >>>
                        >>>
                        >>>>fantastic.. .
                        >>>>Only one thing: on IE6 I get a little white space under the image[/color][/color]
                        >
                        > (3
                        >[color=green][color=darkred]
                        >>>or
                        >>>
                        >>>
                        >>>>4 pixel): is there any way to eliminate it?
                        >>>>
                        >>>>Thanks, PM
                        >>>
                        >>>
                        >>>Try modifying these lines:
                        >>>
                        >>>'<body style="margin:0 ;background:bla ck;">' ,
                        >>>'<img src="'+pD+'" width="'+w+'" height="'+h+'" title="'+tD+'"
                        >>>border="0" >' ,
                        >>>
                        >>>(each one on ONE line only)...make sure you've got the image[/color][/color]
                        >
                        > dimensions
                        >[/color]

                        I tryed anything:
                        anything goes if I resizeBy(0,-3)...

                        PM




                        [color=blue][color=green][color=darkred]
                        >>>correct.
                        >>>[/color][/color]
                        >
                        >
                        > Looks OK here. Try substituting:
                        >
                        > ..............
                        > ..............
                        > HTML = [
                        > '<html>' ,
                        > '<head>' ,
                        > '<title>'+tD+' </title>' ,
                        > '</head>' ,
                        > '<body style="margin:0 ;background:bla ck;">' ,
                        > '<img style="border-width:0;" src="'+pD+'" title="'+tD+'"> ' ,
                        > '</body>' ,
                        > '</html>'
                        > ].join('');
                        > nw = window.open('ja vascript:opener .HTML', nome, features);
                        > if (nw && !nw.closed && nw.focus)
                        > nw.focus();
                        > return false;
                        > }
                        >
                        > Make sure the image size is accurate. Images will resize in the browser
                        > if the dimensions are set in HTML/CSS so, don't trust those properties.
                        > Open the image (url) in its own window, or in your image editor.
                        >[/color]

                        Comment

                        Working...