I have script which will run across multiple pages I don't know about. Say I want to replace some text within it. I attempt to do it by looping through every element on the page and checking if it matches the regex before replacing it but keep getting this...

SCRIPT5007: Unable to get value of the property 'go': object is null or undefined
rs=AItRSTO5xlMcJYBeFTggpnLiO7-4oJljag, line 1533 character 260
SCRIPT5007: Unable to get value of the property 'go': object is null or undefined
rs=AItRSTO5xlMcJYBeFTggpnLiO7-4oJljag, line 1533 character 260

Or on some pages instead of 'go' it lists another property. Anyone know what this could mean?

Like it says, the object is null. Most likely you need to add a null check before checking the object's property.

how do you do that?

        $("body").find("*").filter(function() { 
        return $(this).blah().match(regularExpression); 
        }).each(function() {  
        $(this).html($(this).html().replace(/a/g, "e"));
    });

The problem is at the return point...

Sample:

var node = getElementById('SomeId');
if (node == null)
{
    // not found
}
else
{
    // use node here
}

I've applied your solution to my code but it doesn't work. Here it is:

        $("body").find("*").filter(function() { 
            if ($(this) != null) {
            return $(this).clone();
            }
        });

It appears when the .clone() method is supposed to happen that the error gets thrown.

I am doing this on IE9 by the way..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.