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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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



rork
User

Oct 11, 2005, 8:19 AM


Views: 3879
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:


Code
#!/usr/bin/perl 
use CGI qw(:standard);
use strict;
use warnings;

my $q = new CGI;

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

print <<Page;
<HTML>
<HEAD>
<TITLE>Google search: $search</TITLE>
</HEAD>
<FRAMESET ROWS = '20, *'>
<FRAME NAME = 'top' SRC = '../linkback.html'>
<FRAME NAME = 'main' SRC = 'http://www.google.de/search?q=$search&hl=de
<<&btnG=Starte%20Sucke'>
</FRAMESET>
</HTML>
Page


If you use this you have to change your form:

Code
<!-- Search Google --> 
<FORM method=GET action="cgi-bin/google.pl" target="_blank">
<TABLE bgcolor="#DFDFDF"><tr><td>
<A HREF="http://www.google.de">
<IMG SRC="http://www.google.de/logos/Logo_25gry.gif" 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">

</td></tr></TABLE>
</FORM>

<!-- 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:


Code
<HTML> 
<HEAD>
<TITLE>Google search</TITLE>
</HEAD>
<BODY>
<CENTER>
<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 = "http://google.de/search?q= '
<< + search + '&hl=de&btnG=Starte%20Sucke">');
</SCRIPT>
</IFRAME>
</BODY>
</HTML>

<< 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