in reply to (crazyinsomniac) Re: Talk with Javascript
in thread Talk with Javascript

Thanks for the help! But is it possible to do something like this: print "Content-type: text/html\n\n"; print "<html><head><title>Matches</title>\n"; print "<SCRIPT src=../sort.js>\n"; print "</script></head>\n"; print "<body onload=init(this.form)>\n"; In other words, can CGI send back a HTML page that includes a javascript source file? I don't want to display the javascript functions and variables directly in the CGI program. Thanks, Molly

Replies are listed 'Best First'.
RE: RE: Re: Talk with Javascript
by chromatic (Archbishop) on Sep 10, 2000 at 06:14 UTC
    That's easy to do. Just open up your JavaScript source file, and do a nice tight loop like so:
    open (INPUT, $filename) or warn "Can't open $filename: $!"; print while (<INPUT>); close INPUT;
    You'll have to put that after the headers and in the appropriate spot of your HTML, but it's not tricky.

    I think you can also refer to an external JavaScript source file within the HTML, but maybe I'm confusing it with CSS. That's probably even easier.

RE: RE: Re: Talk with Javascript
by Anonymous Monk on Sep 09, 2000 at 23:13 UTC
    Somehow my sample code is not displayed correctly. Here is it again: print "Content-type: text/html\n\n"; print "<html><head><title>Matches</title>\n"; print "<script src=../sort.js>"; print "</script></head>\n"; print "<body onload=init(this.form)>\n"; In other words, can CGI send back a HTML page that includes a javascript source file? I don't want to display the javascript functions and variables directly in the CGI program. Thanks, Molly