views:

58

answers:

2

I am helping to make improvements to a SharePoint 2007 page that someone else has developed. This stuff is pretty new to me, so please forgive me if this is a noob question.

When I load the page in IE8, I get the following error:

Message: Object doesn't support this property or method
Line: 159
Char: 2
Code: 0
URI: <blah>/Pages/default.aspx

(Note that I replaced the beginning of the URI with <blah> to make it more generic.)

When I view the page source, the following is on line 159:

$("body *").replaceText( /Welcome\s(\w+)\,\s(\w+)/, "$2 $1");

Does this look valid? (Or, am I totally clueless and looking in the wrong place?)

Edit:

Apparently, replaceText is provided by Ben Alman as free plug-in.

I found the following in my page source, so I'm assuming that I am referencing the plug-in correctly. I was able to download the "jquery.ba-replacetext.min.js" successfully. Maybe I'll check it to see if anyone modified the source and introduced a bug.

<script type="text/javascript" src="/_layouts/<blah>/jquery.js"></script>
<script type="text/javascript" src="/_layouts/<blah>/jquery.ba-replacetext.min.js"></script>

Edit 2:

It appears that this is not an issue in Firefox or IE7. I noticed that we are using jQuery 1.3.2. It's possible that this is resolved in the latest version of jQuery. If this is the case, I will post that here.

I sincerely appreciate all the help with this issue. Thank you all very much!

+2  A: 

Does the same error happen in other browsers, most of which have better debugging facilities? When you break on that line in the IE debugger, can you figure out by inspection/watch what's null when it shouldn't be?

Better yet, can you make the change from "Welcome LastName, FirstName" to "Firstname Lastname" in the code on the server, rather than munging it on the client?

DDaviesBrackett
IE8's debugger is pretty good. @bporter: Breaking on the error should be the first step for figuring this out.
Jonathon
Firefox does not seem to report the error. I'll try using IE8's debugger, and I'll post an update here if I learn more from that.
bporter
Using IE8 debugger, it stops on the "replaceText" line. When I add a "watch" on the name, "replaceText", it says, 'replaceText' is undefined. Do I need to make sure that the <script ... src="...jquery.ba-replacetext.min.js"> line is specified in a particular place. Or, can it be specified anywhere in the html?
bporter
@bporter It just needs to be defined before it's used.
Jonathon
Hmm, maybe the problem is not that "replactText" is undefined. Maybe the line is not coded correctly. Unfortunately, I am not able to modify the code (I have to hit up the original developer), but, do you think the problem might be that we need to code the line using "jQuery" instead of "$"? For example: jQuery("body *").replaceText( /Welcome\s(\w+)\,\s(\w+)/, "$2 $1");
bporter
+1  A: 

If the line you posted is accurately the source of the error, I would say there's a problem with how jQuery is included. Your error message says "char: 2", which is $(. Is jQuery used successfully prior to this line?

Jonathon
The line before this is: $(document).ready(function() {
bporter
After reading this again, are you suggesting that maybe jQuery is not included correctly, and that this may be the first bit of jQuery code that gets executed? The "replaceText" line follows immediately after the line I posted in my previous comment. So, maybe it actually falls apart on the $(document) line, and maybe this is the first jQuery code that we execute. I'll think about this a little more. (Please forgive me for my jQuery ignorance! I sincerely appreciate all of your input/advice!)
bporter
@bporter That is what I'm suggesting, and it's easy to check: break on that line in IE8 debugger. Add a watch on '$' -- it shouldn't be undefined. But, you said there was a previous line using $ so I could be wrong.
Jonathon
That's a great suggestion. It appears that '$' is defined, so I assume that jQuery is included correctly.
bporter