Connecting Tech Pros Worldwide Help | Site Map

JavaScript not working with ASP

Web Spinner
Guest
 
Posts: n/a
#1: Jul 19 '05
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\wwwroot, and I placed my JavaScript code in a
file called updated.js under c:\Inetpub\wwwroot\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\wwwroot\scripts\updated.js--------------------------
update = new Date(document.lastModified)
theMonth = update.getMonth() + 1
theDate = update.getDate()
theYear = update.getYear()
document.writeln("<I>Last updated: " + theDate + "/" + theMonth + "/" +
theYear + "</I>")
----------c:\Inetpub\wwwroot\scripts\updated.js--------------------------


---------c:\Inetpub\wwwroot\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="NoteTab Light 4.95">
<META name="author" content="Web Spinner">
<META name="description" content="Test">
<META name="keywords" content="Test">
</HEAD>

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

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

</BODY>
</HTML>
---------c:\Inetpub\wwwroot\x.asp---------------------------------
Bob Barrows
Guest
 
Posts: n/a
#2: Jul 19 '05

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\wwwroot, and I placed my JavaScript code in a
> file called updated.js under c:\Inetpub\wwwroot\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.write "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:
http://www.aspfaq.com/show.asp?id=2147


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"


Web Spinner
Guest
 
Posts: n/a
#3: Jul 19 '05

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.write "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.
Mark Schupp
Guest
 
Posts: n/a
#4: Jul 19 '05

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
www.ielearning.com


"Web Spinner" <webspinner@inbox.lv> wrote in message
news:b7c93f8d.0403282035.50a772b@posting.google.co m...[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.write "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]


Web Spinner
Guest
 
Posts: n/a
#5: Jul 19 '05

re: JavaScript not working with ASP


"Mark Schupp" <mschupp@ielearning.com> wrote in message news:<#ycINnaFEHA.1840@TK2MSFTNGP12.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\wwwroot\scripts to c:\inetpub\wwwroot and
modified the x.asp file accordingly, ie:

<SCRIPT language="JavaScript" 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\wwwroot
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?
Mark Schupp
Guest
 
Posts: n/a
#6: Jul 19 '05

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
www.ielearning.com


"Web Spinner" <webspinner@inbox.lv> wrote in message
news:b7c93f8d.0403300753.3e5ec58@posting.google.co m...[color=blue]
> "Mark Schupp" <mschupp@ielearning.com> wrote in message[/color]
news:<#ycINnaFEHA.1840@TK2MSFTNGP12.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\wwwroot\scripts to c:\inetpub\wwwroot and
> modified the x.asp file accordingly, ie:
>
> <SCRIPT language="JavaScript" 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\wwwroot
> 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]


Web Spinner
Guest
 
Posts: n/a
#7: Jul 19 '05

re: JavaScript not working with ASP


"Mark Schupp" <mschupp@ielearning.com> wrote in message news:<er$HcInFEHA.1840@TK2MSFTNGP12.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\scripts". To fix this problem, I either
had to rename my "scripts" directory to something else, or place
all the javascript files under "c:\inetpub\scripts".

Thanks for all your help.
Closed Thread