473,609 Members | 1,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Syntax error on external JS file beyond end of file

Hi All,

I know this is a novice question that I should be able to solve through
searching but I have Googled my fingers off and not found anything that
seems to help.

I have the following HTML file:
---
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
Hi There. <a href="javascrip t:doit()">Click Me</a>
</body>
</html>
---

The following js file:
--
function doit() {
alert("I did it");
}
--

Running htm file locally (double click) gives me security warning (XP
SP 2) but if I then select "allow script to run" everything works fine.

But when I serve page through IIS (localhost) I get a syntax error line
4 char 4. Of course there is no line 4 in the js file.

This HAS to be something simple I am missing but I have tried:
- with and without language attribute in script tag
- relative and absolute paths for the js file
- with and without Mime type for js set in IIS

Only remaining thing I guess it could be is file permissions but
everything has execute on it as far as I can see.

Any help appreciated.

Thanks,

Josh

Oct 14 '05 #1
7 4479

"Josh" <js*****@gmail. com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
Hi All,

I know this is a novice question that I should be able to solve through
searching but I have Googled my fingers off and not found anything that
seems to help.

I have the following HTML file:
---
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
Hi There. <a href="javascrip t:doit()">Click Me</a>
</body>
</html>
---

The following js file:
--
function doit() {
alert("I did it");
}
--

Running htm file locally (double click) gives me security warning (XP
SP 2) but if I then select "allow script to run" everything works fine.

But when I serve page through IIS (localhost) I get a syntax error line
4 char 4. Of course there is no line 4 in the js file.


this is line 4

<script type="text/javascript" src="test.js"></script>

Line for of the file in which the.js is included. That said I cant see what
the error is though. is the path of the file OK ?
Oct 14 '05 #2
Lee
Josh said:

Hi All,

I know this is a novice question that I should be able to solve through
searching but I have Googled my fingers off and not found anything that
seems to help.

I have the following HTML file:
---
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
Hi There. <a href="javascrip t:doit()">Click Me</a>
</body>
</html>
---

The following js file:
--
function doit() {
alert("I did it");
}
--

Running htm file locally (double click) gives me security warning (XP
SP 2) but if I then select "allow script to run" everything works fine.

But when I serve page through IIS (localhost) I get a syntax error line
4 char 4. Of course there is no line 4 in the js file.

This HAS to be something simple I am missing but I have tried:
- with and without language attribute in script tag
- relative and absolute paths for the js file
- with and without Mime type for js set in IIS

Only remaining thing I guess it could be is file permissions but
everything has execute on it as far as I can see.


If the browser can see line 4 to report an error, it's not a
permissions problem. The browser downloads the file and then
compiles and executes it. Source code doesn't need execute
permissions.

Try your page in a browser that gives useful error messages
(eg, Firefox).

Oct 14 '05 #3
Josh said the following on 10/14/2005 4:16 PM:
Hi All,

I know this is a novice question that I should be able to solve through
searching but I have Googled my fingers off and not found anything that
seems to help.
Did you try searching the comp.lang.javas cript archives for "getting
useful error messages" ?
I have the following HTML file:
---
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
Hi There. <a href="javascrip t:doit()">Click Me</a>
<URL: http://jibbering.com/faq/#FAQ4_24 >
</body>
</html>
---

The following js file:
--
function doit() {
alert("I did it");
}
--

Running htm file locally (double click) gives me security warning (XP
SP 2) but if I then select "allow script to run" everything works fine.
Yes, that is a default XP SP2 setting, but it can be disabled:

Tools>Internet Options>Advance d>"Allow active content....."
But when I serve page through IIS (localhost) I get a syntax error line
4 char 4. Of course there is no line 4 in the js file.
Error message line numbers are not relative to the js file, they are
relative to the current windows HTML. And even then that is not always
true. Error line 0 char 0 is a common one.
This HAS to be something simple I am missing but I have tried:
- with and without language attribute in script tag
- relative and absolute paths for the js file
- with and without Mime type for js set in IIS


Place the script contents into the page itself, test it and then go from
there.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 14 '05 #4
Let me follow up my own post, I guess I wasn't clear enough. I do
appreciate all the feedback.

This is a dumbed down example. I tried the same thing with a 563 line
JS file and got error on line 565. And a 32 line JS file and the error
was on line 33. So the line number does have something to do with the
length of the JS file. I dumbed down to the simplest example for this
post and to verify it was really a problem.

Secondly, I don't need to run on another browser to see useful error
messages because there is no *real* langauge error (and yes, it works
fine when the script is put right into the html file, so do the much
large JS files I really want to use, but I don't want to clutter the
HTML file with 563 lines of Javascript).

It has something to do with the way the file is referenced in the HTML
file or configuration (hence my question about file permissions) and
possibly with the use of IIS as a server and IE as a browser. But no
choice on either of those, IIS will be the server this gets deployed on
and IE is still the #1 browser out there.

I can't believe I am the first person to come across this.

Thanks.

Oct 15 '05 #5
Lee
Josh said:
Secondly, I don't need to run on another browser to see useful error
messages because there is no *real* langauge error


You're getting an error message from a browser that is known to give useless
error messages. Why in the world would you imagine that a browser that gives
useful messages won't help you, just because the error doesn't have anything to
do with a "real" language error?

Oct 16 '05 #6
What can I say, when he is right he is right.

The problem was that automatic document footer is turned on in IIS and
it is appending the footer to the JS file. So the cause of this is
found.

Thanks for all the help.

Josh

Oct 17 '05 #7
Josh said the following on 10/17/2005 10:50 AM:
What can I say, when he is right he is right.

The problem was that automatic document footer is turned on in IIS and
it is appending the footer to the JS file. So the cause of this is
found.

Thanks for all the help.


Now, if we can just manage to teach you to quote what you are replying to.

Please quote what you are replying to.

If you want to post a followup via groups.google.c om, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 17 '05 #8

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

Similar topics

1
8400
by: Aravind | last post by:
we have two files: 1. rc4.c (defines one function "create_pin()") 2. MyImpl.c(calling the function "create_pin()"),This implements JNI method. 1.When I am trying to create .dll file with one file rc4.obj(rc4.c),it is creating the .dll file without any error. Command : ILINK32 rc4.obj 2.But,when we are trying to create .dll file with two .obj files with following errors.
2
5827
by: Mary | last post by:
Hello, I am having a problem with the cl compiler. I have written a C class (RegConnect.c) which uses Win32 API functions such as RegOpenKey, RegCloseKey etc. Initially when I was trying to create a dll, using the cl compiler I was getting many unresolved external errors, Example 1 below (8 in total, 7 to do with the registry function calls and 1 from wsprintfA call) as I hadn't included the AdvAPI32.lib file. So I created a LINK...
3
3723
by: JeffM | last post by:
I have a .dat file on a remote server that seems to be locked. I have tried to FTP to it and delete it, rename it, copy over it and I get the error. "Could not copy temporary files to the output directory" Anybody have any idea why this file is locked? What do I have to do to release it? TIA ~jeff
8
2212
by: Kevin Murphy | last post by:
Using PG 7.4.3 on Mac OS X 10.2.8, the following "insert into ... select ..." statement completed and then announced a syntax error, which seems bizarre. (Don't be confused by the fact that the two tables referred to (public.identifiers and original.identifiers) have slightly different column names.) egenome_dev=# \!cat /Users/murphy/cvs/egora/sql/data_port/port_identifiers.sql INSERT INTO public.identifiers (element_id, name, source,...
5
3621
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As New System.Diagnostics.Process 'p.Start(MDEPDirStr & "macrun.exe", sPPTOut) p.Start("C:\WINDOWS\SYSTEM32\CALC.EXE") 'p.Start("C:\WINDOWS\SYSTEM32\macrun.exe", sPPTOut)
2
2748
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include <string>
5
2845
by: eberesche | last post by:
Hello, as a novice in ASN.1 I have me to a project in C ++ under use of ASN.1 - structures risquély. One of my colleagues means, this would deal something with masochism ;-). Result should be a DLL which provides the exchange of documents between a DMS and a remote data base. My developing environment is MSVS v.7.1, and the ASN.1 - source texts are generated with the compiler asn1c-0.9.20. Therefore I have in the project cpp-, as well as c...
3
1653
by: carllucas | last post by:
I'm having issues trying to pass a variable basically I get information from an external xml document like this function run(file) { t = file.getElementsByTagName("category"); for(i=0; i<t.length; i++) { element = file.getElementsByTagName("category").childNodes.nodeValue;
2
5313
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: 1>make_buildinfo.obj : error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _make_buildinfo2 Ask on python-list@python.org . - Josiah
0
8139
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8232
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8408
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5524
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4032
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4098
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2540
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 we have to send another system
1
1686
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.