modperl-javascript_to_do_popup_windows_presented_without_finger_shaking_unfortunately

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



To: <modperl@apache.org>
From: David Young <dyoung@nettonettech.com>
Subject: Re: How to create a browser popup window
Date: Tue, 20 Nov 2001 09:38:51 -0500

"Domien Bakker" <domien.bakker@staff.zeelandnet.nl> wrote:

> Can anybody give me the "golden" tip of creating a popup
> browser window from my mod_perl handler? I want to fill in
> this popup window with results generated within my
> handler.

> Is there a module available from CPAN which can handle this?

This is not really a mod_perl question. Pop-up windows can only be created
using client-side scripting like Javascript. Your handler would need to
output the necessary Javascript to cause the pop, like:

<script>
    url = "/pop/source.html";
    name = "popwin";
    h = 250;
    w = 350;
    var theWin = window.open(url, name, 'scrollbars=yes, resizable=yes,
                toolbar=no, height='+h+', width='+w);
    theWin.focus();
</script>

For more information on how that works, read Javascript docs:
http://developer.netscape.com/docs/manuals/?content=javascript.html

===

To: Ben Demonte <bdemonte@erols.com>
From: Nick Tonkin <nick@rlnt.net>
Subject: [OT] Re: How to create a browser popup window
Date: Tue, 20 Nov 2001 10:21:07 -0800 (PST)

Off topic but in the interests of, if not less popup windows, then at
least less broken ones:

You must include code to deal with the fact that you may have already
opened a popup window. Something like this:

    <SCRIPT LANGUAGE="JavaScript">
      <!-- Hide
        var popupwin = null;
        function popup(loc,ww,hh) {
          var mywidth = (ww + 10);
          var myheight = (hh + 10);
          var myspecs = "'menubar=1,status=1,resizable=1,location=1,titlebar=1,toolbar=1,scrollbars=1,width=" + mywidth + ",height=" + myheight + "'";
          
          if (popupwin == null || popupwin.closed) {
            popupwin = window.open (loc, 'popupwin', myspecs);
          } else {
            popupwin.close();
            popupwin = window.open (loc, 'popupwin', myspecs);
            
            // If all your windows should be the same
            // size then comment out the above two lines and
            // uncomment the next two lines

            //  popupwin.focus();
            //  popupwin.location.href = loc;
          }
        }
    </SCRIPT>

    <A HREF='javascript://' onClick='popup("foo.gif",300,200); '>Look at foo</A>



This one is good for calling with just an image as the href. You can use
any code you like, including the other example posted here. Just remember
to test whether you already have the window open or not and act
appropriately.


===

To: "Nick Tonkin" <nick@rlnt.net>
From: "Rob Bloodgood" <robb@empire2.com>
Subject: RE: [OT] Re: How to create a browser popup window
Date: Tue, 20 Nov 2001 12:25:56 -0800

> You must include code to deal with the fact that you may have already
> opened a popup window. Something like this:

That is simply not true.  window.open() with a named window ('popupwin', in
your example) ALWAYS reuses that window, on every browser I've ever been
able to test.  The second call to window.open, with a new URL, simply
refreshes the contents of the popup w/ the new URL.  Note, this is *only*
true for named windows.  Windows without a window name string as the second
parameter to window.open() will open a new window every time.

It can, however, be a good idea to explicitly call focus() on your child
window, because in the situation I've just mentioned, if the child window's
url is refreshed, it is NOT automatically brought to the foreground.

The original post was wondering how to put mod_perl output in a popup
window.  The answer is simply top call window.open() with the URL of the
mod_perl handler as its location.

If one is trying to be "responsible" about the window(s) being open, adding
a link like

<a href="javascript:window.close()">CLICK HERE CLOSE THIS WINDOW</a>

in the child window is usually reasonably simple for the user to understand.
Of course, the normal caveats about users understanding something still
apply...

A corrected version of your sample script follows.  It's much simpler now...
:-)

>     <SCRIPT LANGUAGE="JavaScript">
>       <!-- Hide
>         var popupwin = null;
>         function popup(loc,ww,hh) {
>           var mywidth = (ww + 10);
>           var myheight = (hh + 10);
>           var myspecs =
> "'menubar=1,status=1,resizable=1,location=1,titlebar=1,toolbar=1,
> scrollbars=1,width=" + mywidth + ",height=" + myheight + "'";
>
>             popupwin = window.open (loc, 'popupwin', myspecs);
>		  popupwin.focus();
>         }
>     </SCRIPT>

>  <A HREF='javascript:' onClick='popup("foo.gif",300,200)'>Look at foo</A>

===

To: "Rob Bloodgood" <robb@empire2.com>
From: "Domien Bakker" <domien.bakker@staff.zeelandnet.nl>
Subject: RE: [OT] Re: How to create a browser popup window
Date: Fri, 23 Nov 2001 13:23:45 +0100

This is a multi-part message in MIME format.

------_=_NextPart_001_01C17419.B1ED373E
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello,

Thanks for all the window tips.
I have fixed it with out using any javascript.
just mention <BASE TARGET=3D_blank> in your html head
and give TARGET=3D_self to the references which should be opened within
the=20
parent window.

Thanks,

Domien
-----Original Message-----
From: Rob Bloodgood [mailto:robb@empire2.com]
Sent: Tuesday, November 20, 2001 9:26 PM
To: Nick Tonkin
Cc: mod_perl
Subject: RE: [OT] Re: How to create a browser popup window


> You must include code to deal with the fact that you may have already
> opened a popup window. Something like this:

That is simply not true.  window.open() with a named window ('popupwin',
in
your example) ALWAYS reuses that window, on every browser I've ever been
able to test.  The second call to window.open, with a new URL, simply
refreshes the contents of the popup w/ the new URL.  Note, this is
*only*
true for named windows.  Windows without a window name string as the
second
parameter to window.open() will open a new window every time.

It can, however, be a good idea to explicitly call focus() on your child
window, because in the situation I've just mentioned, if the child
window's
url is refreshed, it is NOT automatically brought to the foreground.

The original post was wondering how to put mod_perl output in a popup
window.  The answer is simply top call window.open() with the URL of the
mod_perl handler as its location.

If one is trying to be "responsible" about the window(s) being open,
adding
a link like

<a href=3D"javascript:window.close()">CLICK HERE CLOSE THIS WINDOW</a>

in the child window is usually reasonably simple for the user to
understand.
Of course, the normal caveats about users understanding something still
apply...

A corrected version of your sample script follows.  It's much simpler
now...
:-)

>     <SCRIPT LANGUAGE=3D"JavaScript">
>       <!-- Hide
>         var popupwin =3D null;
>         function popup(loc,ww,hh) {
>           var mywidth =3D (ww + 10);
>           var myheight =3D (hh + 10);
>           var myspecs =3D
> =
"'menubar=3D1,status=3D1,resizable=3D1,location=3D1,titlebar=3D1,toolbar=3D=
1,
> scrollbars=3D1,width=3D" + mywidth + ",height=3D" + myheight + "'";
>
>             popupwin =3D window.open (loc, 'popupwin', myspecs);
>		  popupwin.focus();
>         }
>     </SCRIPT>

>  <A HREF=3D'javascript:' onClick=3D'popup("foo.gif",300,200)'>Look at
foo</A>


===


the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu