perl output to pop-up window 
Author Message
 perl output to pop-up window

I am trying to have html output from a perl script open in a pop-up
window. I would like to know how I can modify my script or my form to do
so. I am very new to perl and I could use a bit of help. I have an
example of what I'm trying to do at
http://www.*-*-*.com/

The script I am using is as follows:

#!/bin/perl -w
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/html\n\n";

$specurl = param('specurl');
$spectext = param('spectext');
$specheading = param('specheading');

print <<"JADAM";

<HTML>
<HEAD>
<TITLE>$specheading</TITLE>
</HEAD>

<BODY>
<H2>$specheading<br>$spectext<br><img src="$specurl"></H2>
</BODY>

</HTML>
JADAM
;

'spectext' is the specimen description, 'specurl' is the image url, and
'specheading' is the heading for the page.

The page that I would like to use the pop-up's on is at
http://www.*-*-*.com/ ;I want to use hidden fields
to submit the text message and image url to the new window. As is, I am
just using an onClick-open.window script that I found on a freebee site.

I don't even know if what I just said makes sense, but any help would be
GREATLY appreciated.

~Adam


http://www.*-*-*.com/
http://www.*-*-*.com/



Sun, 03 Aug 2003 04:57:34 GMT  
 perl output to pop-up window

Quote:
> I am trying to have html output from a perl script open in a pop-up
> window. I would like to know how I can modify my script or my form to do
> so. I am very new to perl and I could use a bit of help. I have an
> example of what I'm trying to do at
> http://www.mineralcollecting.org/showcase/new.html

Popup windows are a browser feature, controlled by the scripting language
running on the browser.  A Perl CGI script on the server can only pass
content to the browser.  Of course, theres no reason why that content can't
be javascript.

In your case, the current CGI script is fine for passing the content to the
popup window.  Try calling the script from the onClick handler in the client
script.

A more elegant solution would be to store the sample name, text, image
height, width and URL in either a database or a delimited text file.  Your
main sample page would be dynamically generated using a template for the
static parts such as the header and sidebar, and a lookup function that
would generate the links for each sample.  See the many *::Template modules
available on CPAN.  You will probably want to write a generic javascript
onClick handler to open the new window and set a default height and screen
position.  The URL opened by the window would call a second script on the
server.

(main page)

<script language="javascript">
<!--
function showSpecimen(specimen) {
    var queryURL = 'cgi-bin/show_specimen.pl?specimen=' + specimen;
    window.open(queryURL, [window options] );

Quote:
}

-->
</script>

...

<body>

...

    <a href="#" onClick="showSpecimen('feldspar');">Feldspar</a>

Ths script show_specimen.pl is your original script, modified to perform the
lookup and resize the window.

#! /usr/bin/perl -wT
use strict;
use CGI;
use CGI::Carp;

my $q = new CGI;
print $q->header;

# Look up the information
my $spec = $q->param('specimen');

my ($heading, $text, $url, $height, $width) = lookup($spec);

print <<"JADAM";

<html>
<head>
<title>$heading</title>
</head>

<body onLoad='resizeTo($width, $height);'>
<h2>$specheading<br>$spectext<br><img src="$specurl"></h2>
</body>

</html>
JADAM

sub lookup {
    my $spec = shift;
    my ($heading, $text, $url, $height, $width);
    # get the data
    return ($heading, $text, $url, $height, $width);

Quote:
}

HTH

Kurt Stephens

I don't know much about geology, but I'm not an igneous schist!



Sun, 03 Aug 2003 07:04:36 GMT  
 perl output to pop-up window

Quote:



>> I am trying to have html output from a perl script open in a pop-up
>> window. I would like to know how I can modify my script or my form to do
>> so. I am very new to perl and I could use a bit of help. I have an
>> example of what I'm trying to do at
>> http://www.mineralcollecting.org/showcase/new.html
> Popup windows are a browser feature, controlled by the scripting language
> running on the browser.  A Perl CGI script on the server can only pass
> content to the browser.  Of course, theres no reason why that content can't
> be javascript.

The content can be HTML, too!

Using HTML does not preclude being able to pop up a window.

If you are a web developer and did not know this, read:
http://www.w3.org/TR/html401/present/frames.html#h-16.3.2

The HTML spec (HTML 4.0, HTML 4.01 Frameset, HTML 4.01 Transitional,
XHTML 1.0 Frameset, and XHTML 1.0 Transitional) allows for frames. Within
the frames specs, a frame targeted to an unknown window opens a new window
and sets its name to the name specified as the target.

I'd trust that a browser implements HTML 4 long before I'd trust that it
supports JavaScript and that the user has JavaScript enabled. Some
browsers supported frames before HTML 4.0 was final in fact.

This still isn't really a Perl issue, but that doesn't mean it has to be
a JavaScript issue. People will be happy to say, "Yes, we can do for you
what that other language can't. Why don't you do all your programming
in our language?" Why send them to another camp when they don't need to
go there?

Chris

--
Christopher E. Stith
It's not the U in UBE that pisses people off. It's the B.
-- Martien Verbruggen in clp.misc



Sun, 03 Aug 2003 10:50:26 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Pop Ups

2. Pop Ups

3. Perl Batch Job without DOS window popup

4. Can perl make popup window like Javascript

5. PERL/PWS DOS Window popup problem SOLVED !!!

6. PERL/PWS DOS window popup problem ...

7. ssi in popup window, please help!!!

8. new window pop up via button

9. popup windows...

10. Popup Window in Tk

11. Pop Up Window for FormMail

12. ANNOUNCE: Tutorial # 38: A CGI script incorporating a pop-up window

 

 
Powered by phpBB® Forum Software