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

Hi Monks. Here's the problem. I have a text box and a submit button in the html. I enter the url in the textbox and click submit. The CGI script should open the url given in a new window. Can I redirect the new location to a frame? Say I have the link in left frame. When I click on it, the new location opens in right frame. How do I do that?

Replies are listed 'Best First'.
Re: CGI redirect to new window/frame
by moritz (Cardinal) on Nov 05, 2009 at 11:50 UTC
    I don't think the CGI script can influence where a link opens, you have to do that in the HTML in which the link is, and set the target attribute on the link there.

    Still browsers are free to ignore that attribute.

      Using html i can open in a new window. That's simple enough. Let me modify the problem. I have a text box and a submit button in the html. I enter the url in the textbox and click submit. The CGI script should open the url given in a new window.
        Then you still have to solve your problem on the HTML or Javascript side, I don't think you can solve it with Perl.
Re: CGI redirect to new window/frame
by ruzam (Curate) on Nov 05, 2009 at 13:56 UTC

    A simple redirect can be handled from perl with CGI->redirect:

    print $CGI->redirect(-uri => 'http://YourNewUrlHere');

    But what you describe sounds like you probably need to use some javascript in your web page and Perl won't help you. Try googling 'javascript location'.

      does redirect take arguments like -target or -uri??
Re: CGI redirect to new window/frame
by keszler (Priest) on Nov 05, 2009 at 11:47 UTC
    Untested:

    $query->redirect( -location => 'http://somewhere.else/', -target => $frame, );