Is script type="text/perl" OK?

L

lg

I've asked this on a html forum but I'll ask it here also.

I have a counter file on my index page which is like below.
Snippet from index.html:
<script type="text/perl" SRC="http://www.blahblah.com/counter.pl"> </script>

The script is is a perl file which is processed by the server. Is it legal? Will
my counter work (be run as usual)?

Below runs OK too, but I get a "done, but with errors on the page"
<script type="text/javascript" SRC="http://www.blahblah.com/counter.pl">
</script>

What I am trying to do is get rid of the error message and have the counter.pl
execute. Since the server (not the client browser) is doing the running of the
counter.pl I want to know if "<script type="text/perl" SRC="http://.." is
otherwise valid. I could just put the line there and see if I get hits, but I
don't want to find out six months later that it while it does work on many
browsers it does not work on not-so-common-browser and the browser simply quits
interpreting the html on the file and issues a 404 or similar message.
 
J

Joost Diepenmaat

lg said:
I've asked this on a html forum but I'll ask it here also.

I have a counter file on my index page which is like below.
Snippet from index.html:
<script type="text/perl" SRC="http://www.blahblah.com/counter.pl"> </script>

The script is is a perl file which is processed by the server. Is it
legal?

Yes. But then your script is expected to return perl code to the
browser. But unless your script actually returns valid perl and your
browser has a perl scripting plugin (like the ActivePerl PerlScript plugin)
this is probably not what you want.

Note: the <script> tag indicates that whatever is sent *to the browser*
is to be run as a script. There is way and no need to indicate that
something is *generated by a script* on the server side.
Will my counter work (be run as usual)?

Maybe, probably not. I would expect browsers to just ignore (i.e. not
fetch the URL for) script tags with types they can't understand, but I
haven't tested this. If that's true, the only type that's anywhere near
Below runs OK too, but I get a "done, but with errors on the page"
<script type="text/javascript" SRC="http://www.blahblah.com/counter.pl">
</script>

That's probably because your script does not return valid javascript.
What I am trying to do is get rid of the error message and have the counter.pl
execute. Since the server (not the client browser) is doing the running of the
counter.pl I want to know if "<script type="text/perl" SRC="http://.." is
otherwise valid. I could just put the line there and see if I get hits, but I
don't want to find out six months later that it while it does work on many
browsers it does not work on not-so-common-browser and the browser simply quits
interpreting the html on the file and issues a 404 or similar message.

Some people, like me, have browser scripting disabled, so it won't work
any way. Most counter scripts I've seen are called using an <img>
tag. Whatever you use, just make sure you send back the right kind of
response; an image for an <img> tag, a (javascript) script for a
<script> tag etc. Or maybe a 204 NO RESPONSE result will work.

Joost.
 
L

lg

Joost Diepenmaat said:
Yes. But then your script is expected to return perl code to the
browser. But unless your script actually returns valid perl and your
browser has a perl scripting plugin (like the ActivePerl PerlScript plugin)
this is probably not what you want.

Note: the <script> tag indicates that whatever is sent *to the browser*
is to be run as a script. There is way and no need to indicate that
something is *generated by a script* on the server side.


Maybe, probably not. I would expect browsers to just ignore (i.e. not
fetch the URL for) script tags with types they can't understand, but I
haven't tested this. If that's true, the only type that's anywhere near


That's probably because your script does not return valid javascript.


Some people, like me, have browser scripting disabled, so it won't work
any way. Most counter scripts I've seen are called using an <img>
tag. Whatever you use, just make sure you send back the right kind of
response; an image for an <img> tag, a (javascript) script for a
<script> tag etc. Or maybe a 204 NO RESPONSE result will work.


Joost.
 
J

Joost Diepenmaat

lg said:
How would I do it with <IMG> tag

<img src="url-to-some-script-that-returns-an-image">

#!perl -w
use strict;
print "Content-type: image/png\n\n";
binmode STDOUT;
print $string_containing_png_data;
 
S

smallpond

I've asked this on a html forum but I'll ask it here also.

I have a counter file on my index page which is like below.
Snippet from index.html:
<script type="text/perl" SRC="http://www.blahblah.com/counter.pl"> </script>

The script is is a perl file which is processed by the server. Is it legal? Will
my counter work (be run as usual)?

Below runs OK too, but I get a "done, but with errors on the page"
<script type="text/javascript" SRC="http://www.blahblah.com/counter.pl">
</script>

What I am trying to do is get rid of the error message and have the counter.pl
execute. Since the server (not the client browser) is doing the running of the
counter.pl I want to know if "<script type="text/perl" SRC="http://.." is
otherwise valid. I could just put the line there and see if I get hits, but I
don't want to find out six months later that it while it does work on many
browsers it does not work on not-so-common-browser and the browser simply quits
interpreting the html on the file and issues a 404 or similar message.


If you want the perl code to run on the server and include its output
in
the page sent to the browser, then you need to make a server-side
include (SSI).

<!--#include virtual="/cgi-bin/counter.pl" -->

You will also have to enable SSI on the web server and name the file
index.shtml instead of index.html.
--S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top