By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,681 Members | 1,854 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,681 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Kevin Potter wrote:
<snip>
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.
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.