Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Perl output to new browser window?

by spacey (Scribe)
on May 02, 2003 at 18:50 UTC ( #255126=perlquestion: print w/replies, xml ) Need Help??

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

Hi all,
Iím sorry if this has been asked before.
I just need to obtain a better understanding of
I have a script that outputs dynamic results information back to the web browser.
What I like to know is:-
How would I redirect the output to a new browser window?
I have tried looking around and I believe this is not as simple as it sounds.
I have viewed the help notes and see that this has a Ėtarget option but clearly
stats that it does not work on Internet Explorer.

What I need to establish is:-
1, Is what I need?
2, Do I need to combined with some sort of JavaScript?
3, Is this type of thing limited to ether Netscape or Explorer and not both?
4, Is there any good resource I could look at for help with this?

I guess the simplest example I could give for what I am trying to achieve is:

#!/usr/bin/perl print "Content-type: text/html\n\n\n"; print <<END; #### FROM HERE TO END IN NEW BROWSER WINDOW <html> <font color=RED> hello World </font> </html> END

Replies are listed 'Best First'.
Re: Perl output to new browser window?
by chromatic (Archbishop) on May 02, 2003 at 19:14 UTC

    This isn't the job of Perl or CGI. It's the domain of the web browser to decide when and how to create new windows. There's no information in a normal HTML document that says "by the way, this is a new window now".

    That said, there are a couple of answers. One is to change the link target -- if you're using a GET request -- to pop up a new window. Another option is to use JavaScript to open a new window.

    Of course, that will depend on how the user has configured his browser and how well said browser supports JavaScript.

Re: Perl output to new browser window?
by LordWeber (Monk) on May 02, 2003 at 19:16 UTC
    Re: Perl output to new browser window?
    by LordWeber (Monk) on May 02, 2003 at 21:03 UTC
      Re: Perl output to new browser window?
      by Anonymous Monk on May 02, 2003 at 20:14 UTC
        Ok thanks for your comments.

        But I am now very confused I found the below code @

        Which runs a perl script opening a pop window?
        So could you clear up my confusion please?
        Can I use or not?

        #!/usr/bin/perl #file: use CGI qw/:standard/; print header, start_html('Popup Window'); if (!param) { print h1("Ask your Question"), start_form(-target=>'answer'), "What's your name? ",textfield('name'), p(), "What's the combination?", checkbox_group(-name=>'words', -values=>['eenie','meenie','minie','moe'], -defaults=>['eenie','moe']), p(), "What's your favorite color? ", popup_menu(-name=>'color', -values=>['red','green','blue','chartreuse']), p(), submit, end_form; } else { print h1("And the Answer is..."), "Your name is ",em(param(name)), p(), "The keywords are: ", em(join(", ",param('words'))), p(), "Your favorite color is ",em(param('color')); } print end_html;

          The key line there is start_form(-target=>'answer'). The 'target' attribute tells the browser which window to display the response in. If a window with the specified name doesn't exist, a new window will be created.

          90% of every Perl application is already written.
      Re: Perl output to new browser window?
      by Anonymous Monk on May 02, 2003 at 20:28 UTC
        Hi all
        Thanks all. i have got my head around it at last
        Thanks all


      Log In?

      What's my password?
      Create A New User
      Node Status?
      node history
      Node Type: perlquestion [id://255126]
      Approved by Tanalis
      and the web crawler heard nothing...

      How do I use this? | Other CB clients
      Other Users?
      Others musing on the Monastery: (5)
      As of 2021-04-17 20:50 GMT
      Find Nodes?
        Voting Booth?

        No recent polls found