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

To present a page, we use print "Location: $page\n\n"; How can I present the same page in a new window in the Perl script. Thank you for any help.
  • Comment on How to open a page in a new window within Perl script

Replies are listed 'Best First'.
Re: How to open a page in a new window within Perl script
by brian_d_foy (Abbot) on Feb 26, 2006 at 20:53 UTC

    From a CGI script, you can use the Window-Target HTTP header.

    print <<'HTTP'; Location: $page Window-target: new HTTP
    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
      Thank you, brian! That is the answer I am seeking!
Re: How to open a page in a new window within Perl script
by jZed (Prior) on Feb 26, 2006 at 19:22 UTC
    Use the HTML target attribute to the anchor tag that points to the script:
    <a href="myScript" target="myWindow">myAnchor</a>

      Just a few notes on style. While this technique should in many cases work, target is a deprecated attribute (not valid XHTML, so use a transitional DOCTYPE, or none). Opening new windows is generally frowned on due to its poor showing in UI usability testing.

      If you must, it's considered best practice to add a phrase near the link text indicating "opens in a new window", which you might do as part of the link's title attribute.

      UPDATE: /me kicks self, mumbles. If I could vote I would obviously have to ++ brian for you know, actually answering the OP's question.