Calling External Scripts

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Smoke

    Calling External Scripts

    We had a javascript calling a Cold Fusion page (.cfm) and it was working for
    2 years. Suddenly yesterday or today its decided it doesn't want to work
    anymore. I'm picking up somebody elses code I don't know all of the rules
    here.

    All of the examples I've found really want .JS files if called with a script
    tag, example below.

    <script src="http://www.website.com/javascripts/xxx.js">
    </script>

    Question - is this a hard rule or can you call a file with any extention?

    Thanks in advance.


  • Sergey I.Grachyov

    #2
    Re: Calling External Scripts

    Hi!

    You can call file with any extension as long as
    this file output correct javascript.

    For example - no correct javascript here


    --
    Sergey.
    This url return “online”:false in any case: https://www.freelancer.com/ajax/user/isOnline.php?user_id=10663 As for example: {“status”:”success”,”result”:{“online”:false,”last_login”:1494827557}} Please, use your own id to check your status. My status is “online”:false in any case (any computer, any web browser). Support ticket #ROT-837-43885 sent 10 days ago. Result: ” We’ll forward your concern to the Engineering team and we’ll contact you again […]


    [color=blue]
    > We had a javascript calling a Cold Fusion page (.cfm) and it was working[/color]
    for[color=blue]
    > 2 years. Suddenly yesterday or today its decided it doesn't want to work
    > anymore. I'm picking up somebody elses code I don't know all of the rules
    > here.
    >
    > All of the examples I've found really want .JS files if called with a[/color]
    script[color=blue]
    > tag, example below.
    >
    > <script src="http://www.website.com/javascripts/xxx.js">
    > </script>
    >
    > Question - is this a hard rule or can you call a file with any extention?
    >
    > Thanks in advance.
    >
    >[/color]


    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Calling External Scripts

      "Smoke" <smoke@xatrium. com> writes:
      [color=blue]
      > We had a javascript calling a Cold Fusion page (.cfm) and it was working for
      > 2 years. Suddenly yesterday or today its decided it doesn't want to work
      > anymore.[/color]

      Well, *something* must have changed on the computer. Unless the
      offending page code has a time bomb included, you must have changed
      either the operating system, the Cold Fusion version, the web serve,
      or some library that something depends on.
      [color=blue]
      > I'm picking up somebody elses code I don't know all of the rules
      > here.[/color]

      Ah. Debugging somebody else's code. Always ... interesting.
      [color=blue]
      > All of the examples I've found really want .JS files if called with a script
      > tag, example below.
      >
      > <script src="http://www.website.com/javascripts/xxx.js">[/color]

      This is illegal HTML 4. The "type" attribute is required on script
      tags. Add type="text/javascript"
      [color=blue]
      > </script>
      >
      > Question - is this a hard rule or can you call a file with any extention?[/color]

      That depends on the browser. Technically, there shouldn't be any
      restrictions on the name of the file, or on the URL at all (e.g.
      "http://www.example.com/foo/" should be legal). You specify the
      type of the file in the type attribute and it is given by the server,
      so the extension is not important.

      However, some browsers, in some cases, try to second guess the type of
      file using the extension. The *safest* is to use a recognizable extension
      that doesn't match some other type of file.

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: Calling External Scripts

        Smoke wrote:[color=blue]
        > <script src="http://www.website.com/javascripts/xxx.js">
        > </script>[/color]

        That's invalid HTML 4. The `type' attribute is missing here, so the script
        could simply be ignored and all the variables and functions it defines could
        become undefined in the context of this particular HTML document. Use

        <script src="..." type="text/javascript"></script>

        instead.


        HTH

        PointedEars

        Comment

        • Richard Cornford

          #5
          Re: Calling External Scripts

          "Lasse Reichstein Nielsen" <lrn@hotpop.com > wrote in message
          news:y8vdyraw.f sf@hotpop.com.. .
          <snip>[color=blue][color=green]
          >>Question - is this a hard rule or can you call a file with
          >>any extention?[/color]
          >
          >That depends on the browser. Technically, there shouldn't
          >be any restrictions on the name of the file, or on the URL
          >at all (e.g. "http://www.example.com/foo/" should be legal).
          >You specify the type of the file in the type attribute and
          >it is given by the server, so the extension is not important.[/color]

          A while back, in response to a question about having servers send
          "text/javascript" content type headers (which apparently have no
          official status in HTTP terms), I did some experiments explicitly
          setting content type headers from a JavaScript generating JSP script. I
          tried a wide range of content type headers including ones that the
          browsers would have had an attitude about in any other context, totally
          fictitious ones and things like "text/html" & "text/plain". And the
          results were that any resource (any file extension, including no
          extension at all) referred to in the SRC of a script tag could be sent
          with any content type header and so long as what showed up contained
          script all of the browsers I tested with happily interpreted and
          executed it.
          [color=blue]
          >However, some browsers, in some cases, try to second guess
          >the type of file using the extension. The *safest* is to use
          >a recognizable extension that doesn't match some other type
          >of file.[/color]

          IE is the browser with the reputation for making its own decisions about
          how to interpret material it receives, but the above tests included IE
          4, 5 and 6 with the results described.

          So putting type="text/javascrpt" in the opening script tag is required
          for valid HTML 4, but beyond that the only thing that seems to matter is
          that what shows up actually contains recognisable JavaScript source
          code.

          Richard.


          Comment

          Working...