Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

'null' is null or not an object

 
Paul Clapham
Sheriff
Pie
Posts: 20958
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been told this message is showing up on my company's web site. And it is... in Internet Explorer, in some applications, the yellow-triangle warning appears with this message. But not in Firefox. The code referenced in the message is this code:


This code is using jQuery, and the message 'null' is null or not an object points at Line 9, Char 2. (If that's worth anything.) Which would be this line:


Background: a couple of years ago the company's website was redesigned, and this code was part of every page. So when we inserted the web applications, we copied their boiler-plate code from the website to our apps, so they would match the look and feel of the web site. Which means that, although I'm not totally useless at Javascript and I'm not totally ignorant of jQuery, it's all a black box to me.

So can anybody tell me what I should be looking for which is making something null in that code?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only that strikes me as possibly being null, is the value of $('.extended').outerWidth(true). Can you check it in a debugger?
 
Paul Clapham
Sheriff
Pie
Posts: 20958
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I turned on Firebug and debugged that line and...

Several years ago when we wrote those web applications, we used Prototype for our AJAX processing. Then the outside company did the redesign, and they used jQuery for some UI features. So now the page contains both jQuery and Prototype. The first thing I saw when debugging was that $('.extended') called a Prototype script. Obviously this is a Bad Thing.

However almost everything in that script refers to CSS classes which don't actually exist in our pages. At any rate having it crash on the first line doesn't affect the page's behaviour in any way. So it looks like the best thing is just to remove it (and jQuery) from the page entirely.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally I'd remove Prototype (which is rather a dinosaur at this stage) but realize that that may not be an option for you.

P.S. jQuery and Prototype can peacefully co-exist on the same page via jQuery's $.noConflict() function.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic