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: Perl Programming Help: Intermediate:
HELP: cgi output to popup window

 



moozie
Deleted

May 15, 2001, 4:31 AM

Post #1 of 2 (520 views)
HELP: cgi output to popup window Can't Post

I am using a postcard script.
When people get a postcard they receive an e-mail with in it a link to pick
up their card.
It looks like:
http://www.mysite.com/cgi/card.cgi?989443021288

The number corresponds with the file on the server containing the message
from afriend and jpeg to come along.

OK, when you click that link the browser opens and the script will read the
data in the "989443021288.dat" file and places the data in the file
makecard.html. Where I want the message to appear I use the code
%%%message%%%. So in the browser I will see the message that was written for
me instead of the %%%message%%%. The makecard.html can be designed according
your own needs and style.

Question:
Before displaying my message in a window I want another webpage to be loaded
in a big window in which I call a smaller browser popup window with
javascript. I want my makecard.html to be displayed in that little popup
window. I created that small browser popup window in that specific file
"makecard.html". So instead of displaying the e-card in that html-file it
loeads a refresh to the desired page in the window and ini the popup it
should display it's e-card, where the %%%message%%% is called. But it
doesn't work. It seems that the variables are only present in the first
html-file (in which I call the popup) and not in the popup itself.

In the cgi script the e-card, triggered by that e-mail link, is created as
follows:

print "Content-type: text/html\n\n";
open(TEMPLATE,"$makecard");
&template;
print $template;

$template = '';

On the server there is a file called "makecard.html" with all the variables
in it used like %%%message%%%


This is the end of the code where the templates are called:

sub template {
while (<TEMPLATE>){
$template .= $_;
}
close(TEMPLATE);

$template =~ s/\%%%PICTURE%%%/$VALUE{'PICTURE'}/g;
$template =~ s/\%%%SENDER%%%/$VALUE{'SENDER'}/g;
$template =~ s/\%%%MAILFROM%%%/$VALUE{'MAILFROM'}/g;
$template =~ s/\%%%MAILTO%%%/$VALUE{'MAILTO'}/g;
$template =~ s/\%%%RECIPIENT%%%/$VALUE{'RECIPIENT'}/g;
$template =~ s/\%%%MESSAGE%%%/$VALUE{'MESSAGE'}/g;
$template =~ s/\%%%CGI%%%/$cgi/g;
$template =~ s/\%%%MAX_DAYS%%%/$MAX_DAYS/g;
$template =~ s/\%%%SHORTDATE%%%/$SHORTDATE/g;
$template =~ s/\%%%url_of_card%%%/$url_of_card/g;
$template =~ s/\%%%HEADER%%%/$CONFIG{'HEADER'}/g;
$template =~ s/\%%%FOOTER%%%/$CONFIG{'FOOTER'}/g;
}

So, is there a way to simply pass on the variables, used in this way, to the
popup window. It seems so simple, but I couldn't find a way to do it. Or any
other suggestions?

Thanx.

Moozie









randor
User

May 16, 2001, 6:50 AM

Post #2 of 2 (512 views)
Re: HELP: cgi output to popup window [In reply to] Can't Post

moozie,

as far as i can tell, the question you are asking is "why wont my data passthrough a popup window?" if so, then thet answer is because it is not keeping a connection through each page, when you open a "new" window, all info that is passed through the "old" window is halted there, but alas, there is a solution..


what you need to do is take the information you need to pass and place it in the url of the popup window like so:


http://www.mysite.com/mainpage.htm<-- this i assume is going to the main page

now you must send that same info afterwards to the popup also:
http://www.mysite.com/cgi/popup/card.cgi?989443021288
to do so, write a small script that will take the info from the "main" page and add it to the redirect, this could be done a few different ways, but the most likely way would be to create the "main" page on the fly, and adding the input into the redirect as so:


#!/usr/bin/perl
$data = @ARGV[0];
print "Content-type: text/html\n\n";
print qq~<html>
<SCRIPT LANGUAGE=javascript>
function popitup() {
var newWindow = open('http://www.mysite.com/cgi/card.cgi?989443021288', 'newwindow');
}
</SCRIPT>
<body onLoad=popitup;>
<h1>Hello!</h1></html>\n~;

you will have to excuse my javascript, as it is not very good, but you should be able to get the point.. you need to 'resend' the info to your new window.

i hope this helps.


 
 


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

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