473,804 Members | 3,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4073
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/rasterTriangleD OM.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
3907
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
1943
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 beginning, so my scripts don't work giving syntax errors. can you give me a solution?
6
1705
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 that you don't have to reference them within the (x)html document files.
17
2789
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 language="javascript" src="../scripts/base.js" type="text/javascript" /> } </script> Obviously this would cause n error but this would give you an idea of what I'm looking to do. I know I can do this with a simple include but...
8
1995
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 no longer works. Can someone explain why this is happening? How can I fix this so that the JS is generic enough to work on every aspx to be included in the external JS file? The external JS file looks like this right now function...
1
1582
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 makered(obj) in colors.js from shapes.js? I suspect these are simple issues... or maybe not... I'm learning my ropes with AJAX ... Thank to anyone who can help out.
10
2413
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 external file with the "src" attribute, it does not work anymore. Does anybody have an idea if there is any way (be it clean and simple or as a workaround) to access the code of external scripts as well? I read, that if there is something like
2
5369
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 the format of data that has been entered by the user and makes sure that all required fields have been filled out. On the login page, between the <head></headtags I have the following syntax: <script language="javascript"...
3
2082
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 php script is being called first it has access to the environment variables, but the Python script does nt. How can I forward the variables or call the Python script in such a way where it can access those variables? These are the type of...
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9591
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10594
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10331
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.