CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: General Discussions: General Questions: Re: [felix] Link back / close Window in form?: Edit Log


Oct 11, 2005, 8:19 AM

Views: 7443
Re: [felix] Link back / close Window in form?

I thought about using perl to create what you call 'google.html' but I'm not sure if you can even use perl

Here's the perlcode:

use CGI qw(:standard);
use strict;
use warnings;

my $q = new CGI;

print $q->header;
my $search = $q->param('q');

print <<Page;
<TITLE>Google search: $search</TITLE>
<FRAMESET ROWS = '20, *'>
<FRAME NAME = 'top' SRC = '../linkback.html'>
<FRAME NAME = 'main' SRC = '$search&hl=de

If you use this you have to change your form:

<!-- Search Google --> 
<FORM method=GET action="cgi-bin/" target="_blank">
<TABLE bgcolor="#DFDFDF"><tr><td>
<A HREF="">
<IMG SRC="" border="0"
ALT="Google" align="absmiddle"></A>
<INPUT TYPE=text name=q size=31 maxlength=255 value="">
<INPUT TYPE=hidden name=hl value=de>
<INPUT type=submit name=btnG VALUE="Starte Suche">


<!-- Search Google -->

The bold text is the url of the perl script, the italic text is useless and can be deleted if you want to.

The main trick is to get the paramaters and make the url for the search yourself, it can be done by any programming language as long as you can grab the parameter 'q' from the url and place it in the next. For as far as I know this isn't possible with html only, but you might try to find a way to do it with JavaScript and use an iframe instead of normal frames:

<TITLE>Google search</TITLE>
<A HREF = 'index.html'>Back</A>
<A HREF = 'JAVASCRIPT:"window.parent.close()"'>Close window</A><BR>
<SCRIPT LANGUAGE = 'javascript'>
var search;
# Try to find a way to load the parameter q into search
document.write('<IFRAME SRC = " '
<< + search + '&hl=de&btnG=Starte%20Sucke">');

<< Remove this and preceding spaces and newline (Now it doesn't spoil the lay out)

Edit: Fixed the missing ;. Fixed the Javascript command so it closes the parent window. Fixed a wrong url in the JavaScript/Iframe code
Don't reinvent the wheel, use it, abuse it or hack it.

(This post was edited by rork on Oct 12, 2005, 1:22 PM)

Edit Log:
Post edited by rork (User) on Oct 12, 2005, 9:56 AM
Post edited by rork (User) on Oct 12, 2005, 1:22 PM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives