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

How would I do this? Also, how would I get parameters from a different frame?

Thanks,
Spidy

Replies are listed 'Best First'.
Re: Embedding CGI into frames?
by shenme (Priest) on Sep 10, 2004 at 04:07 UTC
    In one application where the majority of the work is done with Javascript, upon need the Javascript code builds up a form in one of the frames and submits it. The results then come back to the same frame and are displayed.

    Some people have used invisible frames to interact with CGIs. It's just like normal CGI, except that you take care not to reset the frameset.

    As for parameter sharing among frames, the usual idea is to have variables declared outside of the individual frames, plus some Javascript routines to manage transfering data around between the frames.

    If I sound vague it's because it has been awhile set I set one of those up... three years since I last touched it. Here's some disconnected (and ugly (and old (very old))) snippets: From the first CGI:

    sub CopyHTMLToBrowserPart1 { print <<"EOT"; Content-type: text/html <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-88 +59-1"> <META NAME="Copyright" CONTENT="Copyright (C) 1998 Yes-sir-this- +is-my-baby Consulting All rights reserved."> <META NAME="Author" CONTENT="me"> <META NAME="Description" CONTENT="Page to select administration ac +tions"> <TITLE>Paging Database Maintenance</TITLE> <SCRIPT LANGUAGE="JavaScript" SRC="${PagingAIJSPathWWW}vars.js" ></S +CRIPT> <SCRIPT LANGUAGE="JavaScript" SRC="${PagingAIJSPathWWW}util1.js" ></S +CRIPT> <SCRIPT LANGUAGE="JavaScript" SRC="${PagingAIJSPathWWW}subsu1.js" ></S +CRIPT> <SCRIPT LANGUAGE="JavaScript" SRC="${PagingAIJSPathWWW}subs1.js" ></S +CRIPT> <SCRIPT LANGUAGE="JavaScript"> function initFromDatabaseValues() { EOT }
    These are separate routines as in-between I build up and output the large Javascript data arrays.
    sub CopyHTMLToBrowserPart2 { print <<"EOT"; } initFromDatabaseValues(); // Identify AI CGI version and datestamp versionAICGI = '1.12'; dateAICGI = 'Tuesday, June 27, 2000'; // Where to submit updates; where is Send-a-Page? var PageSubmitActionURL = '$PageSubmitActionURL'; var PageSendPageURL = '$PageSendPageURL'; // Flags identifying support for enhancements var AllowUserAliasEnhancements = $AllowUserAliasEnhancements; ::: ::: // Allow comments from CGI on first screen var InitialMessage ='$JSInitialMessage'; </SCRIPT> </HEAD> <FRAMESET ROWS="160,*" FRAMEBORDER="yes" FRAMESPACING=0 BORDER=3> <FRAME SRC="${PagingAIHTMLPathWWW}blanktop.html" NAME="ftop" MARGIN +HEIGHT=0 MARGINWIDTH=5 SCRO LLING="YES"> <FRAME SRC="${PagingAIHTMLPathWWW}blankbot.html" NAME="fbot" MARGIN +HEIGHT=0 MARGINWIDTH=5 SCRO LLING="YES"> </FRAMESET> <NOFRAMES> Sorry, this page requires that you have a frames-capable browser.<BR> You will not be able to use these facilities. <P> The Netscape Navigator 3.x and Internet Explorer 3.x programs are able to display frames. Please install one of these or a more recent version. </NOFRAMES> </HTML> EOT File blanktop.html basically immediately fetches good stuff, kicking o +ff by using a Javascript onLoad="" event: <HTML><HEAD><TITLE></TITLE></HEAD> <BODY BGCOLOR="WHITE" onLoad="top.OnLoadBlankPageTop()"> </BODY></HTML>
    All this was patched together from various books and hints around the web. The books are better now, I suppose. Good luck.
Re: Embedding CGI into frames?
by Errto (Vicar) on Sep 10, 2004 at 04:10 UTC

    I'm not sure what you mean by embedding CGI into frames. When you have an HTML frameset, you can specify the URL for each frame, and you are perfectly free to have that URL be a CGI program. If you would like to have a single CGI script generate an HTML document that appears in multiple frames, then you should use <iframe> tags within the body of that document.

    For your second question, it is not possible for a server-side CGI program to automatically query the parameters from other frames that happen to be loaded in the client. However, this can be done on the client-side using Javascript. This site has some FAQs that I have found helpful in the past.

Re: Embedding CGI into frames?
by monkey_boy (Priest) on Sep 10, 2004 at 08:41 UTC
    Frames are evil, i prefere to use <div> tags to make it look like a frame even though its only one page, and leaving the scripting all in perl. (Javascript is also a pain, with different browsers supporting different methods)
    I should really do something about this apathy ... but i just cant be bothered
Re: Embedding CGI into frames?
by Spidy (Chaplain) on Sep 10, 2004 at 13:52 UTC
    Well, I tried using <frame src="red.cgi">, and it didn't work. It's still just using the background frame html, and the cgi file isn't being loaded in.

    Also, would it be possible to get the parameters using something like param('framename.varname')?