in reply to "alert" or prompt box from perl cgi script

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.

--
b10m

Replies are listed 'Best First'.
Re: Re: "alert" or prompt box from perl cgi script
by suaveant (Parson) on Jan 07, 2004 at 22:11 UTC
    Unfortunately, that will leave you on a blank page. Not sure that that really is what is wanted.

                    - Ant
                    - Some of my best work - (1 2 3)

A reply falls below the community's threshold of quality. You may see it by logging in.