473,466 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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\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---------------------------------
Jul 19 '05 #1
6 3796
Web Spinner wrote:
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!
What does "doesn't work" mean? We're not looking over your shoulder. Do you
get error messages? Incorrect results?

I know the example doesn't actually have any asp code in it,


.... 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"
Jul 19 '05 #2
> What does "doesn't work" mean? We're not looking over your shoulder. Do you
get error messages? Incorrect results?
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.

I know the example doesn't actually have any asp code in it,
... making this question off-topic for this newsgroup. :-)


Well it's supposed to work alongside ASP code, I only gave a simplified
example to help illustrate my problem. :-)

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.


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.
Jul 19 '05 #3
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" <we********@inbox.lv> wrote in message
news:b7*************************@posting.google.co m...
What does "doesn't work" mean? We're not looking over your shoulder. Do you get error messages? Incorrect results?


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.

I know the example doesn't actually have any asp code in it,


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


Well it's supposed to work alongside ASP code, I only gave a simplified
example to help illustrate my problem. :-)

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.


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.

Jul 19 '05 #4
"Mark Schupp" <ms*****@ielearning.com> wrote in message news:<#y**************@TK2MSFTNGP12.phx.gbl>...
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


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?
Jul 19 '05 #5
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" <we********@inbox.lv> wrote in message
news:b7*************************@posting.google.co m...
"Mark Schupp" <ms*****@ielearning.com> wrote in message

news:<#y**************@TK2MSFTNGP12.phx.gbl>...
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


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?

Jul 19 '05 #6
"Mark Schupp" <ms*****@ielearning.com> wrote in message news:<er**************@TK2MSFTNGP12.phx.gbl>...
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


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.
Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: VictorG | last post by:
Hello, I am new to JS and am trying to add some HTML into a JS function. So that when called the script as well as the HTML will be invoked. Is there some type of embed mechanism, sort of the...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
1
by: Muhammad Abdullah | last post by:
Hi am having some problems with the javascript confirm. i have it working fine on one page and it doesnt even pop up at the other. The code on the working page is, private void...
1
by: den2005 | last post by:
Hi everybody, I am confused and still looking why this codes is not working. Can anyone notice or know why this code is not working? Thanks in advance. Code working: <form id="form1"...
11
by: Nathan Sokalski | last post by:
I add several JavaScript events (onchange, onkeypress, etc.) to Controls using the Add method of the Attributes collection. However, if the JavaScript code contains certain characters, such as & or...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.