Is script type="text/perl" OK?

Discussion in 'Perl Misc' started by lg, Jan 14, 2008.

  1. lg

    lg Guest

    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.
     
    lg, Jan 14, 2008
    #1
    1. Advertising

  2. lg <> writes:

    > 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
    universally supported is javascript. Personally, I'd use an <img> tag
    instead.

    > 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.
     
    Joost Diepenmaat, Jan 14, 2008
    #2
    1. Advertising

  3. lg

    lg Guest

    Joost Diepenmaat <> wrote:

    >lg <> writes:
    >
    >> 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
    >universally supported is javascript. Personally, I'd use an <img> tag
    >instead.
    >
    >> 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.


    How would I do it with <IMG> tag


    >
    >Joost.
     
    lg, Jan 14, 2008
    #3
  4. lg <> writes:
    > 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;

    --
    Joost.
     
    Joost Diepenmaat, Jan 14, 2008
    #4
  5. lg

    smallpond Guest

    On Jan 14, 6:50 am, lg <> wrote:
    > 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
     
    smallpond, Jan 14, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. heyo
    Replies:
    3
    Views:
    961
    Dan Pop
    Apr 1, 2004
  2. pete
    Replies:
    4
    Views:
    830
    Dan Pop
    Apr 2, 2004
  3. Yevgen Muntyan

    #define ALLOCIT(Type) ((Type*) malloc (sizeof (Type)))

    Yevgen Muntyan, Feb 9, 2007, in forum: C Programming
    Replies:
    10
    Views:
    946
    Yevgen Muntyan
    Feb 13, 2007
  4. kj
    Replies:
    5
    Views:
    430
  5. joe
    Replies:
    3
    Views:
    428
    Jeremy J Starcher
    Apr 15, 2008
Loading...

Share This Page