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

Hi Perlmonks.

I'm absolutely need you opinion about this 'redirecting' things.
I tried to redirect user to another page which is created by another Perl program. I can't use CGI.pm. In this redirection, I want to open the page in the parent ( whole frame ).
This is due to the fact that the page which is created by the Perl program also consists of a few frames.
But when I use Window-target=<_parent>, it will still open the page in the self frame instead of the whole frame. This is part of the lines:
my $url = $baseurl."abc.pl?datafile=$new_file"; print "Location: $url\n"; print "Window-target: <_parent>\n\n";
Any suggestion will be appreciated.
Regards

Replies are listed 'Best First'.
Re: open a page in whole frame without using CGI.pm
by Ovid (Cardinal) on May 28, 2002 at 04:16 UTC

    gdnew claimed: "I can't use CGI.pm.".

    Okay, I'll bite. I actually have a few programs out there where I print headers manually, rather than use CGI.pm. This is invariably because these are small programs and I can't see the point of loading 6,000 lines of code to print a "Content-type: text/html\n\n" header. However, it's not the case that I can't use CGI.pm. It's that I choose not to do this. I don't break the rules because I don't know them. I break the rules because I do know them.

    In your case, it's entirely possible that you don't need CGI.pm. However, your claiming that you "can't" use it raises my suspicions. Why can't you, and can you show me the code you typically use for form parsing?

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: open a page in whole frame without using CGI.pm
by mattriff (Chaplain) on May 28, 2002 at 03:17 UTC
    I'm guessing you've read perlfaq9 (or a similar example)?

    Have you tried omiting the > and < and just using:

    print "Window-target: _parent\n\n";
    yet? That might have better results. The example in perlfaq9 does reference <FrameName> in it's example, but I don't believe you should literally use > and <. They are just there to emphasize that you should replace FrameName with your frame's name.

    Other than that, it could be a browser issue? That's not standard HTTP (as far as I know), and googling on the topic a bit turns up complaints about that header and IE.

    - Matt Riffle

      I've tried it out. Still doesn't work.
      May be browser problem
      Thanks anyway for your help
Re: open a page in whole frame without using CGI.pm
by newrisedesigns (Curate) on May 28, 2002 at 03:43 UTC

    You may need to put the target information in the <a> tag in your page. Something along the lines of <a href="abc.pl?name=value+pairs" target="_parent"> Perhaps you are calling this redirect through some other means (form post, call to hypothetical index.pl). If so, please post the information/scenario, and we can help you out.

    Also, just another note of reference, I hope you will untaint your variables. Passing a "datafile" through a query string is really unsafe.

    Hope that helps!

    John J Reiser
    newrisedesigns.com

      I agree. If you are doing a redirect anyways, there can hardly be any reasons not to go for "_parent" right away. If it is a form post, form also has the attribute "target", so just do as you would any link. The drawback being that it will send all posts from that form to that frame (see below).

      If you want to conditionally open in the same frame or in the top frame depending on what was posted, or which button was pressed in a form, then you are pretty much out of luck, if you want to be cross-platform. You can do this easily enough with onSubmit javascripts - if all your users have javascript, and has it enabled. Or you can try using non-standard headers like you do now. None of which will ever work reliably, and unless it is some inhouse production where you can control the end users browser, I'd suggest a rethinking of your design.

      Like Ovid below, I am also very curious as to the "can't" use CGI.pm. Does that mean you don't know how, or is it possible that there (still) exists an installation where CGI.pm isn't available?


      You have moved into a dark place.
      It is pitch black. You are likely to be eaten by a grue.
Re: open a page in whole frame without using CGI.pm
by joshua (Pilgrim) on May 28, 2002 at 04:04 UTC
    If you want the redirection more "automatic" than just a link, you could use javascript.print qq[<script language="javascript"><!--\nparent.location.replace("$url");//--></script>];

    Joshua

Re: open a page in whole frame without using CGI.pm
by wardk (Deacon) on May 28, 2002 at 15:31 UTC
    I don't think in this case you want _parent. _parent loads into the "parent frame".

    If you want the frames gone, you probably want "_top" instead. this will load in the top-level window, replacing any frames.