473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.
Jul 20 '05 #1
4 4041
Hi!

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

For example - no correct javascript here
http://www.website.com/javascripts/xxx.js

--
Sergey.
http://www.takereal.com/freelance/

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.

Jul 20 '05 #2
"Smoke" <sm***@xatrium.com> writes:
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.
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.
I'm picking up somebody elses code I don't know all of the rules
here.
Ah. Debugging somebody else's code. Always ... interesting.
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">
This is illegal HTML 4. The "type" attribute is required on script
tags. Add type="text/javascript"
</script>

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


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 - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
Smoke wrote:
<script src="http://www.website.com/javascripts/xxx.js">
</script>


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

Jul 20 '05 #4
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:y8**********@hotpop.com...
<snip>
Question - is this a hard rule or can you call a file with
any extention?
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.


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.
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.


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.
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: bba | last post by:
os:xp pro sp1 ie 6.2800.1106 For some reason any java scripts that refers to 'external' fails: example: external.menuArguments.document.body.style.zoom="100%"; error message:
10
by: Pasquale | last post by:
hello wverybody... i've got a terrible matter with JS my browsers (either IE and NN) load the external scripts uncorrectly...they load the files from the half part of them and not from the...
6
by: Mellow Crow | last post by:
Just discovered this technique. Is this old hat? Would there be any disadvantage to doing this? In your external .js file: /* Summary: includes external scripts in this external script so...
17
by: CES | last post by:
All, I was wondering if their is a way of loading an external script fill from within a script?? <script language="javascript" type="text/javascript"> function test(var){ <script...
8
by: Flip | last post by:
I have a website that's using Master pages (very cool). But when I put JS on there (to close the browser for example) coming from an external file, when I navigate away from the first page, the JS...
1
by: carllucas | last post by:
I'm struggling to understand how to use external css files with external jscript scripts? plus, does anyone know how to access function between jscripts? for example how would I call function...
10
by: Stefan Weber | last post by:
Hi, I'm trying to access the JavaScript code contained in a <scripttag via its "text" attribute. This works well, if the code is embedded in the HTML page. However, when the code is in an...
2
by: Debbie | last post by:
I have always used VBScript but now need to convert my syntax to JavaScript. In an external file, I have a function that is called when a user clicks a button on a login page. The function checks...
3
by: Anthony Smith | last post by:
In my php page I am calling a Python cgi. The problem is that originally the Python script was being called directly and it could access the environment variables that were being set. Now since the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.