The simplest way would be to do something like this:
sub alert { print "Content-type: text/html\n\n"; print "<script>alert('hello')</script>"; }
Please note that you're printing HTML, so "javascript:alert..." is just interpreted as text. You need to tell your browser that your're using a script (in fact, I believe it's more like <script language="Javascript">, but I never use it).
But if you're programming CGI (more than just this), you also might want to look into the CGI module, which offers you the "header" function, which takes care of the header. This way, you can also easily print "start_html" and "end_html", to provide somewhat more of an HTML page.
In reply to Re: "alert" or prompt box from perl cgi script
by b10m
in thread "alert" or prompt box from perl cgi script
by argv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |