Welcome to WebmasterWorld Guest from 54.242.72.36

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

     

Purple Martin

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

WebmasterWorld Senior Member 10+ Year Member



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");

...

daveVk

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

WebmasterWorld Senior Member 5+ Year Member



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.

penders

10:04 am on Oct 6, 2006 (gmt 0)

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



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.

Rambo Tribble

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

WebmasterWorld Senior Member 10+ Year Member



What does the error message say?

Purple Martin

11:47 pm on Oct 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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".

Rambo Tribble

12:26 am on Oct 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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]

daveVk

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

WebmasterWorld Senior Member 5+ Year Member



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month