Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

External JS File Problem

Status
Not open for further replies.

acent

Technical User
Feb 17, 2006
247
US
Greetings,

This is in reference to thread215-1553252 in the HTML, XHTML & CSS (Cascading Style Sheets) forum. At their advisory, this is the better forum for the question.

Any help is appreciated.

"If it's stupid but works, it isn't stupid."
-Murphy's Military Laws
 
In my experience, there are three common reasons for IE to throw a syntax error in JS files:

1. You actually have a syntax error.
2. The path to the JS file is incorrect, and it therefore cannot be loaded.
3. You have HTML-style <!-- --> comments inside your JS file at the top and bottom.

We can obviously rule out point 1, because you say your JS works if it is inline. So, you'll need to confirm that the path is correct and that you have no HTML-style comments inside your JS file.

Failing that, post a URL to the page in question.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Thanks Dan for the post.

Unfortunately, 2 and 3 don't fit. 2 because the error knows how many lines of code I have in the external file, so the file must have been found. 3 just because I stopped putting those HTML comments in my JavaScript years ago.

However, alls not lost. Since this is an intranet site, I can't exactly post a link to the offending page. However, I did create a page you can view:

Here's the fun part - on that page, everything is good. No errors. When I take the exact same code and put it on my internal web host, errors crop up.

Differences to note - ac-ent.com is hosted by php on *nix, and my internal host is asp2.0 on iis6 W2k3. I know that no patches have been installed on the internal host.

This problem is really ticking me off.

"If it's stupid but works, it isn't stupid."
-Murphy's Military Laws
 
I'm getting this error on the page you posted

Error: document.getElementById(toggle_fld) is null
Source File: Line: 71

--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Yes, you would get that on that page after clicking on a date. That is expected because field does not exist.

The syntax error you're not getting is when the page loads.

"If it's stupid but works, it isn't stupid."
-Murphy's Military Laws
 
I'm with Dan,

I can't see the error and therefore cannot help you, sorry. I can, however offer a few more ideas to check:

1. If you remove the code altogether from your intranet site, does the error still pop-up? Maybe it's in a different script?

2. Move the script tag into the <head></head> of your document - this prob won't solve it, but it's worth a shot.

3. Do you have any other external js files being loaded? If so, try removing them and keeping this one to see if the error persits.




--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
any luck with this? If not...maybe in the function "toggle_sm_cal", try parsing the mousex / y values to an int before adding 10?

Just trying things at random...

Code:
(parseInt(mousex) + 10) + "px";
(parseInt(mousey) + 10) + "px";

--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
No dice yet, but thank you both for the posts. I do appreciate the help.

As for the 3 questions above:
1. The errors do not go away. They do change based on the number of lines of code. In other words, if I delete every line, the error still pops up, only references line 1 char 1.

2. The dang error just won't leave!

3. I did some experimenting. I have one other external JS file. While testing, I found the exact same error popping up on the other file. This raised an eyebrow. I have one other site hosted on this internal server and started playing. I noticed that the same code would not have an error on the other site. I checked the IIS and NTFS and the sties are identical.

I did try and open the js file and did not get any permissions errors.

I'm tempted to start playing with converting the JS to a usercontrol and seeing if I can just get the ASPX page to drop the code in so it appears to be an inline script, but that sounds to me like I'm overcomplicating the obvious here.

"If it's stupid but works, it isn't stupid."
-Murphy's Military Laws
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top