473,385 Members | 2,003 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,385 software developers and data experts.

<script src="foo.HTML" type="text/javascript"> ???

Does the file extension matter when including a JavaScript file in an HTML
page?

Normally, one would include a JavaScript file in an HTML page using
<script src="foo.JS" type="text/javascript">

However, I have found that I can use an alternate file extension, such as
<script src="foo.HTML" type="text/javascript">

It works fine with my IE 6 and Mozilla. Will it work with other browsers?

- David D.

P.S., Why, you may ask, would I want to do such a crazy thing? My web site
host uses a web-based HTML editor. Unfortunately it only allows you to edit
files that have .HTM or .HTML extensions.


Jul 23 '05 #1
9 13351
"David D." <da*****************************@comcast.net> wrote in message
news:x9********************@comcast.com...
Does the file extension matter when including a JavaScript file in an HTML
page?

Normally, one would include a JavaScript file in an HTML page using
<script src="foo.JS" type="text/javascript">

However, I have found that I can use an alternate file extension, such as
<script src="foo.HTML" type="text/javascript">

It works fine with my IE 6 and Mozilla. Will it work with other browsers?

- David D.

P.S., Why, you may ask, would I want to do such a crazy thing? My web site host uses a web-based HTML editor. Unfortunately it only allows you to edit files that have .HTM or .HTML extensions.


AFAIK, any extension will work. In fact, ASP developers often assign ".asp"
as the extension which "hides" the source of the script; that is, a visitor
can't load the source code as a page by typing in the URL of the include.
Jul 23 '05 #2
In article <7o********************@comcast.com>, Ne**@McKirahan.com
says...
"David D." <da*****************************@comcast.net> wrote in message
news:x9********************@comcast.com...
Does the file extension matter when including a JavaScript file in an HTML
page?

Normally, one would include a JavaScript file in an HTML page using
<script src="foo.JS" type="text/javascript">

However, I have found that I can use an alternate file extension, such as
<script src="foo.HTML" type="text/javascript">

It works fine with my IE 6 and Mozilla. Will it work with other browsers?

- David D.

P.S., Why, you may ask, would I want to do such a crazy thing? My web

site
host uses a web-based HTML editor. Unfortunately it only allows you to

edit
files that have .HTM or .HTML extensions.


AFAIK, any extension will work. In fact, ASP developers often assign ".asp"
as the extension which "hides" the source of the script; that is, a visitor
can't load the source code as a page by typing in the URL of the include.


Does that hide any client-side code. Surely the ASP engine only parses
any code that's in the ASP delimiters. Got a demo URL of this
behaviour?

--
Hywel http://kibo.org.uk/
I do not eat quiche.
Jul 23 '05 #3
David D. wrote:
However, I have found that I can use an alternate file extension,
such as <script src="foo.HTML" type="text/javascript">

It works fine with my IE 6 and Mozilla. Will it work with other
browsers?


It will work on old Netscape browsers (3.x) only if the web server
sends the correct MIME type "application/x-javascript". Maybe the
execution in other browsers does also depend on the sent MIME type,
but in MSIE 4+, Netscape 4+, and Mozilla/Firefox it certainly does
not.

ciao, dhgm
Jul 23 '05 #4
"Hywel Jenkins" <hy**********@hotmail.com> wrote in message
news:MP***********************@news.individual.net ...
In article <7o********************@comcast.com>, Ne**@McKirahan.com
says...
"David D." <da*****************************@comcast.net> wrote in message news:x9********************@comcast.com...
Does the file extension matter when including a JavaScript file in an HTML page?

Normally, one would include a JavaScript file in an HTML page using
<script src="foo.JS" type="text/javascript">

However, I have found that I can use an alternate file extension, such as <script src="foo.HTML" type="text/javascript">

It works fine with my IE 6 and Mozilla. Will it work with other browsers?
- David D.

P.S., Why, you may ask, would I want to do such a crazy thing? My
web site
host uses a web-based HTML editor. Unfortunately it only allows you
to edit
files that have .HTM or .HTML extensions.
AFAIK, any extension will work. In fact, ASP developers often assign ".asp" as the extension which "hides" the source of the script; that is, a visitor can't load the source code as a page by typing in the URL of the

include.
Does that hide any client-side code. Surely the ASP engine only parses
any code that's in the ASP delimiters. Got a demo URL of this
behaviour?

--
Hywel http://kibo.org.uk/
I do not eat quiche.

http://www.planetsourcecode.com/vb/s...eId=7252&lngWI
d=4

"Prevent unauthorized viewing of website javascript and style sheet files.
Simply rename all your style and javascript files to the .asp extension."

However, they're still in the browser's cache.
I can't remember but here's a skeleton of it:

<< includer.asp >>

<% Const cASP = "includer.asp" %>
<html>
<head>
<title><%=cASP%></title>
</head>
<body>
<script type="text/javascript" src="included.asp"></script>
</body>
</html>
<< included.asp >>

<% {something} %>
document.write("included.asp");
Perhaps I should just say "Nevermind!" as I'm not sure anymore.

Maybe someone else will jump in...
Jul 23 '05 #5
McKirahan wrote:
[...]
I can't remember but here's a skeleton of it:


Can you point us at an example that actually uses this? Because I can't see
how this can possibly work.

In order for your web browser to execute the Javascript code, it has to be
downloaded, which means anything can download it.

--
+- David Given --McQ-+ "I must have spent at least ten minutes out of my
| dg@cowlark.com | life talking to this joker like he was a sane
| (dg@tao-group.com) | person. I want a refund." --- Louann Miller, on
+- www.cowlark.com --+ rasfw

Jul 23 '05 #6
Any modern browser doesn't care what the extention is. Just be sure to
keep the type="text/javascript" attribute in the script tag, so that
the browser knows what it expects.

In E-commerce, I have often used the looping feature of a server-side
language category listing page, in JSP, PHP or whatever, to create
external JS files that document.write() out options for a drop down
menu on other pages. The server grabs all the necessary info from the
database table, and the JSP page will print out the proper JS for you.

You're external script src tag could look like this, then:

<script src="/mypath/category.jsp?id=12345"
type="text/javascript"></script>
Thus, you sort of have dynamic javascript.

Jul 23 '05 #7
In article <xs********************@comcast.com>, Ne**@McKirahan.com
says...
"Hywel Jenkins" <hy**********@hotmail.com> wrote in message
news:MP***********************@news.individual.net ...
In article <7o********************@comcast.com>, Ne**@McKirahan.com
says...
"David D." <da*****************************@comcast.net> wrote in message news:x9********************@comcast.com...
> Does the file extension matter when including a JavaScript file in an HTML > page?
>
> Normally, one would include a JavaScript file in an HTML page using
> <script src="foo.JS" type="text/javascript">
>
> However, I have found that I can use an alternate file extension, such as > <script src="foo.HTML" type="text/javascript">
>
> It works fine with my IE 6 and Mozilla. Will it work with other browsers? >
> - David D.
>
> P.S., Why, you may ask, would I want to do such a crazy thing? My web site
> host uses a web-based HTML editor. Unfortunately it only allows you to edit
> files that have .HTM or .HTML extensions.

AFAIK, any extension will work. In fact, ASP developers often assign ".asp" as the extension which "hides" the source of the script; that is, a visitor can't load the source code as a page by typing in the URL of the

include.

Does that hide any client-side code. Surely the ASP engine only parses
any code that's in the ASP delimiters. Got a demo URL of this
behaviour?

--
Hywel http://kibo.org.uk/
I do not eat quiche.

http://www.planetsourcecode.com/vb/s...eId=7252&lngWI
d=4

"Prevent unauthorized viewing of website javascript and style sheet files.
Simply rename all your style and javascript files to the .asp extension."

However, they're still in the browser's cache.


There's more to it that just renaming your files. I just tested it, and
the browser simply displays the JavaScript source:
http://www50.brinkster.com/hyweljenkins/asptest.asp

--
Hywel http://kibo.org.uk/
I do not eat quiche.
Jul 23 '05 #8
On Fri, 21 Jan 2005 07:21:20 -0600, McKirahan <Ne**@McKirahan.com> wrote:

[snip]
AFAIK, any extension will work.
Of course. Browsers shouldn't care about extensions, only the MIME type
sent by the server (though we know that isn't always the case). However,
the server will care about the extension as that's used to determine the
file type and hence the MIME type sent. Using an extension associated with
a different type probably isn't a good idea. At least with server-side
languages you can send your own Content-Type header.
In fact, ASP developers often assign ".asp" as the extension which
"hides" the source of the script; that is, a visitor can't load the
source code as a page by typing in the URL of the include.


The only "solution" I can think of at the moment along those lines is to
check the Referer [sic] header and make sure that it contains the domain
for the site. However, relying on an optional header[1] is a stupid thing
to do.

Mike
[1] Users can usually prevent the inclusion of the Referer header as a
privacy option.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #9
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:opsky0l7g8x13kvk@atlantis...
On Fri, 21 Jan 2005 07:21:20 -0600, McKirahan <Ne**@McKirahan.com> wrote:

[snip]
AFAIK, any extension will work.


Of course. Browsers shouldn't care about extensions, only the MIME type
sent by the server (though we know that isn't always the case). However,
the server will care about the extension as that's used to determine the
file type and hence the MIME type sent. Using an extension associated with
a different type probably isn't a good idea. At least with server-side
languages you can send your own Content-Type header.
In fact, ASP developers often assign ".asp" as the extension which
"hides" the source of the script; that is, a visitor can't load the
source code as a page by typing in the URL of the include.


The only "solution" I can think of at the moment along those lines is to
check the Referer [sic] header and make sure that it contains the domain
for the site. However, relying on an optional header[1] is a stupid thing
to do.

Mike
[1] Users can usually prevent the inclusion of the Referer header as a
privacy option.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.


Thanks for reminding me.

Here's what I used a few years ago:

<%
If Request.ServerVariables("HTTP_HOST") <> "localhost" Then
If Trim(Request.ServerVariables("HTTP_REFERER")) = "" Then

Response.Write("<html><head><title>Failed</title></head><body></body></html>
")
Response.End
End If
End If
%>

This was at the beginning of JavaScript "include" files with an ".asp"
extension.

I stopped using it because Norton's Firewall blocks the HTTP_REFERER.
Jul 23 '05 #10

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

Similar topics

13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
9
by: Arash Dejkam | last post by:
Hi All, Is it possible to write on an <OBJECT type="text/html"> using document.write() from within the html containing that tag the way we write on a popup window? I couldn't do that after a lot...
6
by: rob | last post by:
Hi I'm trying to create a "roll-up" effect when a window loses focus and then "roll-down" when it regains focus. This statement works properly with every browser I can get my hands on EXCEPT...
6
by: Jon Davis | last post by:
I recently learned how to do an <OBJECT> alternative to <IFRAME> in current browsers using: <object id="extendedhtml" type="text/html" data="otherpage.html" width="250" height="400"></object> ...
23
by: Loony | last post by:
I have got a code like this in HTML section in ASP file which includes javascript file! The script works under MS IE but doesn't with Firefox! Can anybody tell me what is wrong? <HTML>...
22
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the...
37
by: Jan Wagner | last post by:
Hi, can't figure this one out, what's the CSS way to specify the language? In HTML it would be simply an lang="xx" attribute, or XHTML xml:lang="xx", but, how about in CSS? This would be...
10
by: Gernot Frisch | last post by:
Hi, I'm currently writing: <span onclick="window.open(...);">Klick Here</span> but I want to use the <a href> for this, since it is defined in the css script the way I want my link to open....
1
by: tilt | last post by:
Hello, I use an object element to replace the iframe element in ie, like this: <object id="x_obj" data="http://.../" type="text/html"> <iframe name="x_if" id="x_if"...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...

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.