Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display two new windows from a CGI script

Status
Not open for further replies.

cginewbie

Programmer
Jan 20, 2002
24
US
How do I display two new windows from within a CGI script?

print "Location:
only take you to teh new location within the same window. How do I display two new windows once the script is invoked?
THis is without using javascript?

How about with javascript?

thanks
 
You can't do it without using javascript. You might be able to do it with javascript by creating (or redirecting) to a page that has an onLoad function which opens another new window. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
I agree it would be easier to spawn the new window with the onLoad function from the redirected page. This would be the easiest way.

CGI is a server side process and it is extremely difficult to have an effect on the clients machine from the sever in this manner, if not impossible.

Javascript is client side process and does give limited capabilities to have an effect on the client machine and process, like spawning new browser windows.

CGI and Javascript together are what you need. These two are often a powerfull web tool.
 
Without having specifically tried the scenario you're attempting, I'm pretty certain you can split CGI output to two windows (if I understand your question correctly).

Let's say your parent HTML document defines two frames named "top" and "bottom." The following example is admittedly very oversimplified so you can focus on the method:

--- HTML SAMPLE --

Code:
<HTML><FRAMESET COLS=100% ROWS=&quot;50,50&quot; BORDER=0>

<FRAME NAME=&quot;top&quot; SRC=&quot;/cgi-bin/script.cgi?top&quot; SCROLLING=AUTO MARGINWIDTH=0 MARGINHEIGHT=0>

<FRAME NAME=&quot;bottom&quot; SRC=&quot;/cgi-bin/script.cgi?bottom&quot; SCROLLING=AUTO MARGINWIDTH=20 MARGINHEIGHT=0 TOPMARGIN=0 LEFTMARGIN=20 RIGHTMARGIN=20>
</HTML>
--- END HTML SAMPLE --

--- PERL SAMPLE --
Code:
#!/usr/bin/perl

print &quot;content-type: text/html\n\n&quot;;
print &quot;<HTML><BODY>\n\n&quot;;

if ($ENV{QUERY_STRING}=~/top/i){
 print &quot;output that goes to the top frame\n&quot;;
} elsif ($ENV{QUERY_STRING}=~/bottom/i){
 print &quot;output that goes to the bottom frame\n&quot;;
}
print &quot;</BODY></HTML>\n&quot;;
exit;
--- END PERL SAMPLE --

Hope that is helpful,

Craig Craig Richards
cgi@CraigRichards.com
free download of AdminPro for debugging CGIs and remote filemanagement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top