DGM has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on How do I use a JavaScript script in Perl-CGI?

Replies are listed 'Best First'.
Re: How do I use a JavaScript script in Perl-CGI?
by jonknee (Monk) on Jan 23, 2002 at 07:46 UTC
    Well if I understand right you want a Javascript to do something on an HTML page via Perl (using CGI)? In this case you would just plop the code into the script after you send the headers. Correct? Maybe I'm missing something... :)
Re: How do I use a JavaScript script in Perl-CGI?
by metadoktor (Hermit) on Jan 23, 2002 at 09:42 UTC
    You want to do the following:
    <html> <head> <script src="yourscript.js"> </script> </head> </html>
    See this document for more details.
Re: How do I use a JavaScript script in Perl-CGI?
by windfall (Initiate) on Jan 23, 2002 at 23:38 UTC
    If you are using CGI.pm, you can provide the path to your .js file while you list the other "head elements" (eg title etc.)...something like this...
    #c:\perl\bin\perl use CGI qw/escape unescape/; $query = new CGI; ######################################### print $query->header(); ######################################### #send javascript functions into head #You can include external style sheets, javascript , metatag info etc print $query->start_html(-title => 'Place page title here', -script=>{ +-language=>'javascript', -src=>'path to ->/javascript/functions.js'}); ######################################### #Put your html output here and you are good to go!!!!! ######################################### #Finish CGI.pm Output print $query->end_html; #########################################
A reply falls below the community's threshold of quality. You may see it by logging in.