Problem with document.write("script src=.....")

K

Kevin Potter

We have an application that has been running on IIS4 and IIS5 for
quite some time, without problem We're now migrating to IIS6
(windows/2003), and have run into a what might? be a Javascipt
problem/question...

The snippet of code in question is:

<script language="JavaScript"><!--
document.write("<script src='/fp/"+includename+"'></script>");
// -->></script>

The included filename is a variable, and does not have a .js
extension. It points to a filename among several thousand files. The
included files ARE javascript files, and contain nothing but
javascript.

This code works fine in IIS4 and IIS5. But when moving to IIS6, the
<script> statement is ignored (because the includename does not end
with .js). If (as a test), I do add a .js on the end of the
includename in the script statement (and create a matching include.js
file), then things work fine.

Our problem is we cannot rename the thousands of files to .js
extensions (they are produced and used by other processes, and the
filename changes would mean more changes in these systems).

I've tried specifying the language, and the type, in the script
statement, but it does not make a difference:

<script language="JavaScript"><!--
document.write("<script language='JavaScript' type='text/javascript'
src='/fp/"+includename+"'></script>");
// -->></script>

It still ignores the <script> statement.

I realize this may be an IIS issue, but, maybe it is a Javascript
issue.

1. Can anyone clarify if the .js is REQUIRED on a <script ....>
include within document.write?
2. Can anyone suggest a different way to reference this included
javascript file, knowing the included filenames are already set, and
do not end in .js?

Thanks for your thoughts.
 
R

Richard Cornford

Kevin Potter wrote:
1. Can anyone clarify if the .js is REQUIRED on a <script ....>
include within document.write?

A dot-JS extension is absolutely not required in the URL of a resource
referred to by the SRC attribute of a SCRIPT element. (File name
extensions don't mean anything in the context of a URL.)
2. Can anyone suggest a different way to reference this included
javascript file, knowing the included filenames are already set, and
do not end in .js?

Any web browser that insists on a dot-JS extension on an imported
javascript file is broken. It is much more likely that your problem is
somehow a deficiency in IIS 6.

Richard.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top