JavaScript not working with ASP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Web Spinner

    JavaScript not working with ASP

    I am running Windows 2000 and I can't seem to get my JavaScript
    working with ASP. I placed my HTML code in a file called x.asp
    under c:\Inetpub\wwwr oot, and I placed my JavaScript code in a
    file called updated.js under c:\Inetpub\wwwr oot\scripts.

    When I rename x.asp to x.htm and execute it as a html file,
    the JavaScript code works, however when it's x.asp and I
    execute it by typing in the browser http://localhost/x.asp,
    it doesn't work!

    I know the example doesn't actually have any asp code in it,
    but even when it does, my JavaScript does not work.

    I've looked around, but can't seem to find information on how
    to fix this. Can anyone help me out?


    ----------c:\Inetpub\wwwr oot\scripts\upd ated.js--------------------------
    update = new Date(document.l astModified)
    theMonth = update.getMonth () + 1
    theDate = update.getDate( )
    theYear = update.getYear( )
    document.writel n("<I>Last updated: " + theDate + "/" + theMonth + "/" +
    theYear + "</I>")
    ----------c:\Inetpub\wwwr oot\scripts\upd ated.js--------------------------


    ---------c:\Inetpub\wwwr oot\x.asp---------------------------------
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <HTML>
    <HEAD>
    <TITLE>Test</TITLE>
    <LINK rev="made" href="">
    <META name="generator " content="NoteTa b Light 4.95">
    <META name="author" content="Web Spinner">
    <META name="descripti on" content="Test">
    <META name="keywords" content="Test">
    </HEAD>

    <BODY bgcolor="#FFFFF F" text="#000000" link="#0000FF" vlink=
    "#800080" alink="#FF0000" >

    <SCRIPT language="JavaS cript" src="scripts/updated.js" type=
    "text/javascript">
    </SCRIPT>

    </BODY>
    </HTML>
    ---------c:\Inetpub\wwwr oot\x.asp---------------------------------
  • Bob Barrows

    #2
    Re: JavaScript not working with ASP

    Web Spinner wrote:[color=blue]
    > I am running Windows 2000 and I can't seem to get my JavaScript
    > working with ASP. I placed my HTML code in a file called x.asp
    > under c:\Inetpub\wwwr oot, and I placed my JavaScript code in a
    > file called updated.js under c:\Inetpub\wwwr oot\scripts.
    >
    > When I rename x.asp to x.htm and execute it as a html file,
    > the JavaScript code works, however when it's x.asp and I
    > execute it by typing in the browser http://localhost/x.asp,
    > it doesn't work![/color]

    What does "doesn't work" mean? We're not looking over your shoulder. Do you
    get error messages? Incorrect results?
    [color=blue]
    >
    > I know the example doesn't actually have any asp code in it,[/color]

    .... making this question off-topic for this newsgroup. :-)

    However, I tried your code and cannot reproduce your problem. The page seems
    to "work" fine on my server no matter which extension I use.

    Create a page with only real asp code in it:

    <%response.writ e "hello world"%>

    When you run that in the browser, do you get a page with the words "hello
    world"? If not, you may need to go into your IIS settings and turn asp on. I
    seem to recall that asp is not on by default in IIS6.

    Here is an article for you to look at:



    Bob Barrows



    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Comment

    • Web Spinner

      #3
      Re: JavaScript not working with ASP

      > What does "doesn't work" mean? We're not looking over your shoulder. Do you[color=blue]
      > get error messages? Incorrect results?[/color]

      The javascript code was supposed to display text indicating the date
      of last modification of the x.asp document. It's not doing that. I
      tried a simple statement like document.write( "message") in the javascript
      file and it would not even display that.

      It seems to me like ASP could not locate that the JavaScript files are
      under the "scripts" directory. I am just wondering if I had to
      configure anything in IIS to let ASP know that it can find these files
      under the "scripts" directory? Forgive my ignorance, but I am a bit new
      to ASP.
      [color=blue]
      >[color=green]
      > >
      > > I know the example doesn't actually have any asp code in it,[/color]
      >
      > ... making this question off-topic for this newsgroup. :-)[/color]

      Well it's supposed to work alongside ASP code, I only gave a simplified
      example to help illustrate my problem. :-)
      [color=blue]
      >
      > However, I tried your code and cannot reproduce your problem. The page seems
      > to "work" fine on my server no matter which extension I use.
      >
      > Create a page with only real asp code in it:
      >
      > <%response.writ e "hello world"%>
      >
      > When you run that in the browser, do you get a page with the words "hello
      > world"? If not, you may need to go into your IIS settings and turn asp on. I
      > seem to recall that asp is not on by default in IIS6.[/color]

      Yes that works. All the ASP codes work. It's the JavaScript part
      that doesn't work when it's ran as an ASP document.

      Your help is very appreciated.

      Comment

      • Mark Schupp

        #4
        Re: JavaScript not working with ASP

        Right-click on the page generated by ASP and "view source".
        Make sure that the HTML being generated is as expected.

        --
        Mark Schupp
        Head of Development
        Integrity eLearning



        "Web Spinner" <webspinner@inb ox.lv> wrote in message
        news:b7c93f8d.0 403282035.50a77 2b@posting.goog le.com...[color=blue][color=green]
        > > What does "doesn't work" mean? We're not looking over your shoulder. Do[/color][/color]
        you[color=blue][color=green]
        > > get error messages? Incorrect results?[/color]
        >
        > The javascript code was supposed to display text indicating the date
        > of last modification of the x.asp document. It's not doing that. I
        > tried a simple statement like document.write( "message") in the javascript
        > file and it would not even display that.
        >
        > It seems to me like ASP could not locate that the JavaScript files are
        > under the "scripts" directory. I am just wondering if I had to
        > configure anything in IIS to let ASP know that it can find these files
        > under the "scripts" directory? Forgive my ignorance, but I am a bit new
        > to ASP.
        >[color=green]
        > >[color=darkred]
        > > >
        > > > I know the example doesn't actually have any asp code in it,[/color]
        > >
        > > ... making this question off-topic for this newsgroup. :-)[/color]
        >
        > Well it's supposed to work alongside ASP code, I only gave a simplified
        > example to help illustrate my problem. :-)
        >[color=green]
        > >
        > > However, I tried your code and cannot reproduce your problem. The page[/color][/color]
        seems[color=blue][color=green]
        > > to "work" fine on my server no matter which extension I use.
        > >
        > > Create a page with only real asp code in it:
        > >
        > > <%response.writ e "hello world"%>
        > >
        > > When you run that in the browser, do you get a page with the words[/color][/color]
        "hello[color=blue][color=green]
        > > world"? If not, you may need to go into your IIS settings and turn asp[/color][/color]
        on. I[color=blue][color=green]
        > > seem to recall that asp is not on by default in IIS6.[/color]
        >
        > Yes that works. All the ASP codes work. It's the JavaScript part
        > that doesn't work when it's ran as an ASP document.
        >
        > Your help is very appreciated.[/color]


        Comment

        • Web Spinner

          #5
          Re: JavaScript not working with ASP

          "Mark Schupp" <mschupp@ielear ning.com> wrote in message news:<#ycINnaFE HA.1840@TK2MSFT NGP12.phx.gbl>. ..[color=blue]
          > Right-click on the page generated by ASP and "view source".
          > Make sure that the HTML being generated is as expected.
          >
          > --
          > Mark Schupp
          > Head of Development
          > Integrity eLearning
          > www.ielearning.com[/color]

          I did that and the generated HTML page has exactly the same
          contents as the file "x.asp" as I orignally posted - this of
          course is what's expected. I already did this with my other
          ASP documents which actually has ASP VBscript code in it,
          and it was generated according to the way I want it.

          All the ASP stuff works. It's just the JavaScript that does
          not work. I had the same problem even when running it on
          another machine with PWS on it.

          The JavaScript part works When I moved the javascript files
          from c:\inetpub\wwwr oot\scripts to c:\inetpub\wwwr oot and
          modified the x.asp file accordingly, ie:

          <SCRIPT language="JavaS cript" src="updated.js " type=
          "text/javascript">
          </SCRIPT>

          However, I would like to keep things neat and tidy by
          placing all my external javascript files under the script
          directory.

          My belief is that somehow, opening it as an ASP document
          doesn't allow it to recognize that javascript files
          are under the "scripts" directory. All I did so far
          was create a "scripts" directory under c:\inetpub\wwwr oot
          and placed js files in it.

          Is there anything else I need to configure to let IIS or PWS
          know that javascript files are in a "scripts" subdirectory?

          Comment

          • Mark Schupp

            #6
            Re: JavaScript not working with ASP

            It is the browser that is responsible for retrieving the script file based
            on the HTML code that it is interpreting.

            Can you post exactly what you see in "view source"?

            --
            Mark Schupp
            Head of Development
            Integrity eLearning



            "Web Spinner" <webspinner@inb ox.lv> wrote in message
            news:b7c93f8d.0 403300753.3e5ec 58@posting.goog le.com...[color=blue]
            > "Mark Schupp" <mschupp@ielear ning.com> wrote in message[/color]
            news:<#ycINnaFE HA.1840@TK2MSFT NGP12.phx.gbl>. ..[color=blue][color=green]
            > > Right-click on the page generated by ASP and "view source".
            > > Make sure that the HTML being generated is as expected.
            > >
            > > --
            > > Mark Schupp
            > > Head of Development
            > > Integrity eLearning
            > > www.ielearning.com[/color]
            >
            > I did that and the generated HTML page has exactly the same
            > contents as the file "x.asp" as I orignally posted - this of
            > course is what's expected. I already did this with my other
            > ASP documents which actually has ASP VBscript code in it,
            > and it was generated according to the way I want it.
            >
            > All the ASP stuff works. It's just the JavaScript that does
            > not work. I had the same problem even when running it on
            > another machine with PWS on it.
            >
            > The JavaScript part works When I moved the javascript files
            > from c:\inetpub\wwwr oot\scripts to c:\inetpub\wwwr oot and
            > modified the x.asp file accordingly, ie:
            >
            > <SCRIPT language="JavaS cript" src="updated.js " type=
            > "text/javascript">
            > </SCRIPT>
            >
            > However, I would like to keep things neat and tidy by
            > placing all my external javascript files under the script
            > directory.
            >
            > My belief is that somehow, opening it as an ASP document
            > doesn't allow it to recognize that javascript files
            > are under the "scripts" directory. All I did so far
            > was create a "scripts" directory under c:\inetpub\wwwr oot
            > and placed js files in it.
            >
            > Is there anything else I need to configure to let IIS or PWS
            > know that javascript files are in a "scripts" subdirectory?[/color]


            Comment

            • Web Spinner

              #7
              Re: JavaScript not working with ASP

              "Mark Schupp" <mschupp@ielear ning.com> wrote in message news:<er$HcInFE HA.1840@TK2MSFT NGP12.phx.gbl>. ..[color=blue]
              > It is the browser that is responsible for retrieving the script file based
              > on the HTML code that it is interpreting.
              >
              > Can you post exactly what you see in "view source"?
              >
              > --
              > Mark Schupp
              > Head of Development
              > Integrity eLearning
              > www.ielearning.com[/color]

              The view source displayed exactly what was in "x.asp". I didn't want
              to place the same code in this thread again.

              I found out what the problem was. IIS and PWS comes preconfigured
              with a virtual directory called scripts which refers to the
              directory "c:\inetpub\scr ipts". To fix this problem, I either
              had to rename my "scripts" directory to something else, or place
              all the javascript files under "c:\inetpub\scr ipts".

              Thanks for all your help.

              Comment

              Working...