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:
Link back / close Window in form?

 



felix
New User

Oct 6, 2005, 6:31 AM

Post #1 of 5 (4500 views)
Link back / close Window in form? Can't Post

Hi,

maybe someone has an idea. I use Google on my side to let my visitors search in the WWW. I let open the result in a new window. Is there any way to let the form open a new window with i.e. a frame that shows on the top something like "Close Window" and below the results Google delivers? It's not a must, but believe it's a nice feature ....

Thanks,

Felix


rork
User

Oct 8, 2005, 5:22 AM

Post #2 of 5 (4497 views)
Re: [felix] Link back / close Window in form? [In reply to] Can't Post

you can open a page which uses frames, the top frame has your link to close the window, the lower frame the results from google.
--
Don't reinvent the wheel, use it, abuse it or hack it.


felix
New User

Oct 11, 2005, 5:06 AM

Post #3 of 5 (4491 views)
Re: [rork] Link back / close Window in form? [In reply to] Can't Post

Hi,

thanks for the hint, but I'm not really sure how to realize that, since the values given to google come through a form:

<!-- Search Google -->
<FORM method=GET action="http://www.google.de/search" 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 -->


So how do I transfer the input data into one of the frame windows? Background is, that I want to open the output in a new window. So let's say my frame definition file is called "google.html", the upper window "linkback.html" and the result window should be i.e. "google_search.html".

Thanks again,

Felix


(This post was edited by felix on Oct 11, 2005, 5:39 AM)


rork
User

Oct 11, 2005, 8:19 AM

Post #4 of 5 (4484 views)
Re: [felix] Link back / close Window in form? [In reply to] Can't Post

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)


felix
New User

Oct 12, 2005, 12:26 AM

Post #5 of 5 (4480 views)
Re: [rork] Link back / close Window in form? [In reply to] Can't Post

Hi Rork,

I have access to CGI-BIN and can run it. So I created the google.pl made the changes in the form, upload it using ASCI and CHKMOD it with 755 (and tried 777 too), but it ends up in a server 500 error. Anything special I need to do?

Thanks again for your help on this!

Felix


I got it. It was a missing ";" in the google.pl code :-)

Thanks!

Felix


(This post was edited by felix on Oct 12, 2005, 1:08 AM)

 
 


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

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