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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin Potter

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

    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="JavaS cript"><!--
    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="JavaS cript"><!--
    document.write( "<script language='JavaS cript' 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.
  • Richard Cornford

    #2
    Re: Problem with document.write( &quot;script src=.....&quot; )

    Kevin Potter wrote:
    <snip>[color=blue]
    > 1. Can anyone clarify if the .js is REQUIRED on a <script ....>
    > include within document.write?[/color]

    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.)
    [color=blue]
    > 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?[/color]

    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.


    Comment

    Working...