This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes 'null' is null or not an object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark " Watch " New topic
Author

'null' is null or not an object

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Jan 10, 2002
Posts: 60740
    
  65

The only that strikes me as possibly being null, is the value of $('.extended').outerWidth(true). Can you check it in a debugger?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Jan 10, 2002
Posts: 60740
    
  65

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 'null' is null or not an object
 
Similar Threads
jQuery selector using array of objects
transforming value after sorting in bold radiobutton
jsp and two javascript statements
Directory Structure JSP & JS
$(function()) and $("#popupDatepicker39") syntax questions