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

Twice in two days I have found the need to seek the advice of the monks.

I have a problem that I just can't find a solution to. It is pretty simple. I have a Perl CGI script that does lots of stuff depending on context. At one point I need the script to 1) display a frames page and then (subsequently) 2) get rid of that frames page. Step one is easy enough, it is step two that is causing frustration.

OK so I can have the script print a frames page, each frame of which targets the script in a different context and thus displays the desired content in the two frames. No problem so far.

The problem is that I can't get rid of this frames page (once I have created it) so that the next call to the script (from the top frames FWIW) wipes out the frames page and gets back to displaying the script output in a single (unframed page). I know I must be missing something. I just don't know what. It seems that once I create the frame I am stuck with it.

Suggestions greatly appreciated. Please show me how stupid I have been and how easy it actually is! I know I can kludge with a target new but I really don't want multiple Windows if I can avoid it.

cheers

tachyon

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

  • Comment on Create and get rid of frames page with Perl

Replies are listed 'Best First'.
Re: Create and get rid of frames page with Perl
by jonnyfolk (Vicar) on Mar 28, 2003 at 09:18 UTC
    Hi tachyon, I don't know if this is being oversimplistic but if you use target="_top"on any links on the frame page, then you exit the frame without opening new windows as you would have with target="_blank"
Re: Create and get rid of frames page with Perl
by crouchingpenguin (Priest) on Mar 28, 2003 at 13:05 UTC

    How about some simple javascript:

    if (window != top) top.location.href=location.href

    cp
    ----
    "Never be afraid to try something new. Remember, amateurs built the ark. Professionals built the Titanic."
Re: Create and get rid of frames page with Perl
by thpfft (Chaplain) on Mar 28, 2003 at 19:01 UTC

    It depends whether you know at the time of form submission whether you're going to want one frame or many. If you do, then it can almost certainly be done by targeting the link (at '_top', or '_parent', probably).

    if you won't know that, as seems likely, then your output templates will have to be able to force framed and non-framed display. The way in is easy, as you've seen, but the only way to break out of a frame you're already in is with javascript. A universal 'frame me' and 'don't frame me' mechanism that lived at the top of each page would be quite simple to write, but a major pain in practice: that kind of thing disrupts history navigation, often fails when there's more than one domain involved and causes mouth ulcers.

    can you really not use an inline mechanism instead? there aren't many frame-friendly tasks that can't be accomplished with either dhtml or the template toolkit, or both, and you'd save yourself a heap of misery. frames were a terrible kludge when they were new, and time has not been kind to them.

    /me blushes quietly to recall how Modern it all seemed at the time

      It is currently inline. The top 'frame' holds a small form and the bottom 'frame' holds a web page. The problem with this is that CSS on the web page is applied to the top 'frame' when it is inline. Use base solves the relative link issue but I could not stop the application of the CSS reliably. I just posted a pure Perl solution at Break into and out of frames pages with Perl CGI using _top

      I don't know if I will actually use it as I am not much of a frames fan either.

      cheers

      tachyon

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

        css2 allows you to change the rule applied to an element according to the context in which you find it. eg. a rule in the form:

        li em { ... }

        affects only em tags that are immediately contained by li tags. usefully, it works with ids as well as classes. If your original problem is that the formatting needed for the whole page is wrong for one or two elements in the header, then something in this form might work:

        p { padding: 10px; ... } #header { border 1pt solid black; ... } #header p { padding: 0; ... }

        or it might not. You know. Just in case.

        All of which is heading pretty energetically away from the topic, but we could call it the mcfly method: travel back in time far enough and change something to make the problem go away :)

A reply falls below the community's threshold of quality. You may see it by logging in.