0

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?

2
Contributors
5
Replies
18
Views
4 Years
Discussion Span
Last Post by asif49
0

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

0

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...

Edited by asif49

0

Sample:

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

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.

Edited by asif49

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.