Discipulus has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks!

In my stilly newbieness I'm searching a way to open a new browser window via hyperlink but with prefixed dimension and characteristics like menubar and other features.

I know it is possible via (unknown for me) java.
How can I create something like this or like a pop-up windonw via Perl/CGI ???

greetings from still sunny roma
lor*

Replies are listed 'Best First'.
Re: CGI new window fixed dimension
by tachyon (Chancellor) on Sep 30, 2003 at 08:11 UTC

    You are constrained to use Javascript. All Perl can do is give you a new full size window.

    # you can force a new full size window like this: <form method="POST" action="$cgi" target="_new"> .... </form> # or using javascript you can do stuff like: <script language="JavaScript"> <!-- Begin var x = 25; var y = 25; function popUp(URL) { x += 25; y += 25; window.open(URL,"","toolbar=0,scrollbars=1,location=1,statusbar=0, +menubar=0,resizable=1,width=750,height=600,left="+x+",top="+y); } // End --> </script> <a href="javascript:popUp('http://domain.com/cgi-bin/myscript.pl?foo=b +ar')">pop little window</a>

    This particular function pops a new window at (50,50) for the first call (75,75) for the next, etc so they cascade. Hard code x,y as desired.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: CGI new window fixed dimension
by matthewb (Curate) on Sep 30, 2003 at 07:49 UTC
    How can I create something like this or like a pop-up windonw via Perl/CGI ???
    You can't. This is done with Javascript. Look up the `window' object in a reference somewhere.

    You can get your CGI script to output Javascript if you like. The documentation to CGI.pm has a few tips on how to do this.

    MB
Re: CGI new window fixed dimension
by davis (Vicar) on Sep 30, 2003 at 12:56 UTC

    It appears that you've already got the answers you need to do what you want to do. This may come off sounding like a rant - I suppose it is. It's not a personal attack.

    I'm going to ask you to reconsider whether you should do what you want.
    Please don't.
    I browse the web using (most of the time) Mozilla. I've got it set up to ignore Javascript etc, to ban the creation of new windows, even when the site designer uses the target="_new" method listed by tachyon above. I keep my menubars intact at all times, after all, they're my menubars, not the website's.

    What you're trying to do is enforce the way your website is used. What if some of your users are blind/partially-sighted? What if they're using a text-based web browser? Attempts to change their browsers' behaviour will at best go ignored, at worst render your site unusable. Surely you want your website to be as usable as possible?

    I can recommend reading Use it - a pretty helpful starting point for website usability. Yes, I've broken some of the guidelines on that site before.

    Cheers

    davis
    It's not easy to juggle a pregnant wife and a troubled child, but somehow I managed to fit in eight hours of TV a day.
    Update: s/useful/helpful/;
      Here is an informative Anti-Javascript FAQ, too.
      thanks Davis!!

      I have your same ideas about browsing the net but here my case now:

      I'm trying to develop a cgi web interface for the help desk of my job and they all have to use msIE (this is my real world job)..

      this pop-up-like window is intended to show the resolved IP of a gived hostname via a hyperlink..

      My constant goal is resolve my problems WITHOUT have to learning vbc js or C#

      greetings from not-so-sunny-today
      lor*

        Ok, cool, you've vindicated yourself :-) - you're designing for a very specific internal audience (or at least it is until your employer hires somebody that's unable to use IE).

        If you've already resolved the IP address of the hostname, you may wish to try using the "title" attribute of hypertext links - something like the following (which validates just fine):

        <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w +3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>HTML Test</title> <meta content="text/html; charset=ISO-8859-1" http-equ +iv="Content-Type" /> </head> <body> <div> <a href="http://www.perlmonks.org/" title="209.197.123.153">Testing</a +> </div> </body> </html>

        This pops up a "tooltip"-style help box containing the "title" string when you hover your mouse over the link (assuming you've got one). I'd make the link target a HTML page that also produces the same information, so that people who can't use the title information can still get the IP address etc.

        Cheers
        davis
        It's not easy to juggle a pregnant wife and a troubled child, but somehow I managed to fit in eight hours of TV a day.
        Update: Added link to w3c validator.
Re: CGI new window fixed dimension
by jdtoronto (Prior) on Sep 30, 2003 at 12:48 UTC
    What the others have said is perfectly true. Perl, running on the server side, cannot force the characteristics of the created window. All it can do is ask the browser to open a new window.

    You need to use some script that is run on the client side to control a window. Hence the javascript. Fortunately JavaScript is not Java! It is much simpler to use as you can see form the code snippet in another reply.

    jdtoronto