View Full Version : [SOLVED]Here we go again - "runs in Firefox, not in IE"

Mike Robinson
23 Sep 2009, 10:45 AM
The launching code in my app is like this:

The right "<script>" includes, just like the ExtJS manual says...
Include the main program, which declares an app namespace and then creates an object with a public "init" method.
"OnReady()" calls the "init" method of the object.

Firefox loves it. IE doesn't. In IE's new, shamelessly Firefox-like, debugger, at the point where the "Ext.onReady()" call takes place ... there's an "Ext" object but there is no application object.

In other words: the script say, creates the namespace "tlc.crv2.foobar" and creates "tlc.crv2.foobar.app" which has an "init" function which it then calls. In Firebug, that is precisely what we do see.

IE, on the other hand, dies with "tlc.crv2.foobar.app.init is null or not an object." Looking in the Locals display, indeed, there is no "tlc" object to be found although there is "Ext."

My code has been run through the online "jslint" with default options and it now passes. (Yes, I found a few commas...)
The behavior certainly implies that there is a syntax error (according to IE) of some kind ... the complete absence of the application object in the variable space strongly suggests that it failed to parse, but didn't say why.

Firebug produces no Javascript warnings or errors ... I haven't found any corresponding function in IE8.

Further note: Eclipse (Aptana) produces no validation or warning messages concerning this JavaScript file.

Hmmm... do I have to include plugins? Hmmm.... :>

Rats!Aptana does not complain about any of them, either ...

23 Sep 2009, 12:47 PM
Could you post your code?

23 Sep 2009, 1:08 PM
Can't you turn on the debugger im IE8, and get it to stop right where the error is do you can check it out?

Something being null is often indicative of a trailing comma in an Array literal meaning that there is an extra, undefined element.

Mike Robinson
24 Sep 2009, 9:51 AM
Not so far.

It's not that it's "null." It's not even "undefined." The application-object quite literally is not there. "Ext" is there, and a couple of other objects, but when the app halts (in the IE8 debugger) with the failure aforementioned... it's just not there.

I am right now compartmentalizing my code and I'll see if the problem persists. I'll report back.

Mike Robinson
24 Sep 2009, 2:43 PM
~o) Somehow, I just knew it would be this way ... ~o)

Turns out that Firefox will accept <script type="language/javascript" ...> but IE will not.

It wanted: <script type="text/javascript" ...>

... and then it was happy.

So, now the mystery is solved. The reason why it wasn't there was because ... to IE, it wasn't there! ("Ext" was present because the script tag which includes it used the proper "type=", whereas the application-code script-tags, generated elsewhere, did not.)

So much for their "debugger," which did not say anything about the issue.

"Nothing to see here ... move along ... these aren't the 'droids you're looking for ... Move along ..."

24 Sep 2009, 4:05 PM
Just an FYI, the type attribute on a script tag is unnecessary, and I typically just leave it off all together.

Mike Robinson
24 Sep 2009, 5:47 PM
Good advice.

(Thanks for the "[SOLVED]" tag, dear Mods. Indeed it is.)

For the record:

This problem was caused strictly by the "type=" attribute of the HTML <script> tag. Whereas Firefox was permissive about what could be in that tag, IE8 simply ignored the tag without comment. Nothing was produced in IE8's debugger ... perhaps (I say in retrospect) because the IE J(ava)Script engine was somehow not aware that the script existed.

If this tag is present, IE8 requires "text/javascript" and will not accept "application/javascript."

Case closed. ~o)