Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Javascript and Perl... a match never made.

by gryphon (Abbot)
on Jul 19, 2002 at 19:53 UTC ( [id://183421]=note: print w/replies, xml ) Need Help??


in reply to Javascript and Perl... a match never made.

Greetings anonymous,

Several Web browsers are setup to expect that all JavaScript files included via the <SCRIPT SRC=""> tag have the ".js" extention. I ran into this problem about a year ago when I was trying to do something fairly similar. I just changed my file extention of the CGI from ".cgi" to ".js", and things worked perfectly. Of course, you may have to mess around with an .htaccess file somewhere to get the desired result.

Dealing with the GET CGI parameters is a little tricky. You could try putting them into the URL. For example, try:

<SCRIPT SRC="./cgi-bin/jserver.cgi/script=somescript/script.js" TYPE="text/javascript"></SCRIPT>

In this case, there's an enviornment variable created (usually) called "PATH_INFO". It'll be equal to "/script=somescript/file.js" in this case. So now just regex the "somescript" out of that and you're done.

my $script_name = $1 if ($ENV{PATH_INFO} =~ m|/script=([^/]+)/|);

-gryphon
code('Perl') || die;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://183421]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-25 22:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found