Welcome to WebmasterWorld Guest from 54.234.244.30

Forum Moderators: open

Message Too Old, No Replies

JavaScript error out of nowhere

IE fails, Firefox works, can't see a problem with the code

     
4:36 am on Oct 6, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 21, 2002
posts:977
votes: 0


IE is giving me a JavaScript error out of nowhere, Firefox is not giving any error.

The page has a bit of inline JavaScript, then links to a couple of external js files, then a bit more inline JavaScript where the error occurs.

The error message gives a line number that is in the middle of some HTML with no JavaScript at that part of the file, so the line number must be very wrong.

I couldn't see what was causing the error so I added lots of alerts to try and identify the line with the problem.

In the code sample below, the error occurs between the two alerts shown! I have double-checked that there are no strange characters in there.

...

<script type="text/javascript">
alert("OK CCC");
</script>

<script type="text/javascript">
alert("OK DDD");

...

6:00 am on Oct 6, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 3, 2005
posts:1585
votes: 0


In firefox check javascript console for any warnings or error messages. Cant see problem with what you posted, perhaps larger snippet would help, apart from that, validate html and CSS maybe.
10:04 am on Oct 6, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0


The error message gives a line number that is in the middle of some HTML with no JavaScript at that part of the file, so the line number must be very wrong.

The line number that is reported could be in one of your external JS files - although IE always reports the URL of the main HTML page.

12:43 pm on Oct 6, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 14, 2004
posts:1181
votes: 0


What does the error message say?
11:47 pm on Oct 11, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 21, 2002
posts:977
votes: 0


In firefox check javascript console for any warnings or error messages.

The console shows no errors in Firefox. alert("OK DDD") is executed successfully in Firefox. The error only occurs in IE.

Cant see problem with what you posted, perhaps larger snippet would help

I can't see a problem with it either! But that is where it fails: IE shows alert("OK CCC") and then gives an error message before it gets to alert("OK DDD")... the really strange thing is that there is no actual code in between them.

What does the error message say?

It says "Expected Identifier".
12:26 am on Oct 12, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 14, 2004
posts:1181
votes: 0


Well, you may already know this, but here's the page MSDN has on that error: [msdn2.microsoft.com...]

What happens if you put a timeout after the first alert and before the second?

[edited by: Rambo_Tribble at 12:31 am (utc) on Oct. 12, 2006]

1:00 am on Oct 12, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 3, 2005
posts:1585
votes: 0


Try changing alerts to defaultStatus = "Ok CCC"; etc and look at status line at time of error. There may be a timing issue with some other code executing between or during alerts.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members