I have the below set of code to replace specific tags from string.It's not working in Mac safari but working properly in windows chrome and firefox.
Error: TypeError: 'undefined' is not an object (evaluating 'n.innerHTML.replace')
html_data = html_data.replace(/para/g, "p");html_data = html_data.replace(/useful/g, "span");
html_data = html_data.replace(/extra_info/g, "span");
Error: TypeError: 'undefined' is not an object (evaluating 'n.innerHTML.replace')
this means that either n is undefined, or n.innerHTML is undefined. It is not about replace function. Since you did not submit the full code, can you check which one is undefined?
Your error message indicates that you are trying to call the .replace
method of an undefined object.
Therefore your problem is that either n
or n.innerHTML
is undefined (for reasons that cannot be discerned given the limited information we have) and nothing to do with .replace
at all.