Link to home
Start Free TrialLog in
Avatar of tanc02
tanc02

asked on

Is this correct ?

#!/usr/bin/perl

т
 
sub tcy{
print "Content-type: text/html\n\n";
print "<script language=\"JavaScript\">";
print " window.open(\"http://24.17.48.48/thanks.html\");";
print " </script>";
}


It doesn't give me anything. Why ?
Avatar of malec
malec

It works just fine. Any minimized windows on your desktop? Check them.
By the way, why not use perl?

use CGI ':standard';
$url = param("url");  

if ($url) {
    print redirect(-URL=>"$url", -TARGET=>"_new");
   }

I agree, use perl.  Make it easier though than malec:

#!/usr/bin/perl

print "Location: http://24.17.48.48/thanks.html\n\n";

That's all you need.
Avatar of tanc02

ASKER

sorry ! Forget to tell you guys, I wnat to include
width and height and no toolbar in the window.open. can you experts show me how to do it in perl by using javascript ?
Try this. This will set the width and height and you can also
choose what toolbars and scrollbars to show.

This is the javascript function. Put it somewhere on the top of the html:
<script language="javascript">
<!--

function popup(document) {
  var floater = null
  floater = window.open('','popup','width=254,height=381,resizable=1,status=0,scrollbars=0')
  if (floater != null) {
    if (floater.opener == null) {
      floater.opener = self
    }
    floater.location.href = document
  }
}
// -->
</script>


This is how the link should look like:
<a href="javascript:popup('doc.html')">

There is also a problem in Internet Explorer 3.0. You have to
write the full path for link if you want to work it in Internet
Explorer 3.

Regards
Marko
Avatar of tanc02

ASKER

I don't what a link. I want this javascript to be written into PERL script, since PERL must return something after completeing request.

Let 123.com has a CGI MailForm, and after user
hit submit button, and mail request is completed, then send(javascript) to open a new window with
width=200 and height =100 and no toolbar
marko changed the proposed answer to a comment
Use the code I gave in the new HTML which is printed out
by cgi-bin program to open the new window. If you delete
the lines which define this code to be the function the
code will be executed when HTML is loaded. Or put this
function in onLoad handler in html returned by cgi-bin.
Avatar of tanc02

ASKER

i tried it, i didn't see anything
try this........

in addition to doing what you need, this program also centers the newly open windows!!

====================================================
#!/usr/local/bin/perl

use CGI;

$query=new CGI;

print "Content-type: text/html\n\n";
if ($query->param){      ##      The form has been submitted by user
      $text_message=$query->param('text_message');      ##      Read the CGI data
      print "Content-type: text/html\n\n";
      print qq{
      <html>
      <head>
      <script>
      <!--
            function open_win(){
                  var winWidth = screen.width;
                  var winHeight = screen.height;

                  userWindow=open("http://www.amazon.com","NEWWIN","width=600,height=550,status=yes,resizable=yes,location=yes,toolbar=no,directories=no,menubar=no,scrollbars=yes");
                  userWindow.moveTo((winWidth - 600)/2, (winHeight - 650)/2);
                  userWindow.focus();
                  return false;
            }
            //-->      
            </script>
            <title>
            </title>
            </head>
            <body onLoad="open_win();">
            </body>
            </html>
      };

      print "<P><B>The form data was received by the CGI script<BR>\n";
      print "<B>You entered $text_message</b>\n";
}else{
      print"<HTML>\n<HEAD>";

      print "<FORM ACTION=\"".$ENV{SCRIPT_NAME}."\"METHOD=POST>\n";
      print "Enter anything in the text box: <INPUT TYPE=TEXT NAME=text_message VALUE=\"\">\n";
      print "<P><INPUT TYPE=SUBMIT VALUE=\"Submit Now!!\">\n";
      print "</FORM>\n";
}

Avatar of tanc02

ASKER

Is that possible to open up another window without changing the web site ?

Like A.html is a CGI MAILFORM, and it is written
in html, then call a cgi script to send the mail.

Then after user pressed the button, the mail will be sent, but it open an window to confirm that
mail is sent successfully without changing the A.html. If yes, how ?
This is not possible. If you have "submit" button in your
form you have to change the HTML. You can always load
the same HTML document, but you have to change it.

the code seems to be absolutely fine.

please check whether perl exists in the path you have specified in the first line.

hope it help

- amit
Avatar of tanc02

ASKER

points will divided into 25 for marko and 25
for maneshr. Tell me how ?
Avatar of ozo
ASKER CERTIFIED SOLUTION
Avatar of ianB
ianB

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial