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

I am calling a script from within an HTML document using a exec cgi and would like to stop the loading of the rest of that HTML document depending on the return of the script. Any suggestions? Thanks in advance.

Replies are listed 'Best First'.
Re: Stop loading of HTML
by dws (Chancellor) on Feb 04, 2002 at 22:35 UTC
    I am calling a script from within an HTML document using a exec cgi and would like to stop the loading of the rest of that HTML document depending on the return of the script. Any suggestions? Thanks in advance.

    You're on a dead-end road. Without resorting to major duct-tape and chewing gum, with SSI you can't influence how a server handles the enclosing HTML.

    Invert the process. Disguise the CGI as a .hmtl file (if you must), and have it generate the HTML. This gives you complete control.

Re: Stop loading of HTML
by rjray (Chaplain) on Feb 05, 2002 at 01:09 UTC

    This can't be done in the way you want it done. Only the user (or more correctly, the user-agent such as Mozilla or IE) can stop the loading of the current page.

    While it may be possible that M$ has some sort of ASP or ASP-like extension that will seize control of IE to do something like this, that solution would be specific to M$, and not generally applicable.

    You may be better served by having the CGI application responsible for generating the whole page itself, and use one of the many templating engines to express and maintain the HTML part of the display.

    --rjray

Re: Stop loading of HTML
by Cody Pendant (Prior) on Feb 05, 2002 at 05:42 UTC
    Here's one really dumb way to do it.

    Have the exec cgi output the start of an HTML comment tag, and have the end of an HTML comment tag output at the bottom of the page.

    HTML still arrives, but they don't see it.

    Seriously though, why can't you have the whole second half of the page output by an exec cgi? That would solve your problem.
    --

                   ($_='
    jjjjjjuuuuuuuuusssssssssttttttttt
    annnnnnoootttttthhhhheeeeeerrrrrr
    pppeeeerrrrrrrrrrrrllllllllllllll
    haaaaccccccckkkkkkkeeeeeeeerrrrrr
                    ')
                   =~y
                /[a-z]//s
                 ;print;