I am using the following code to check for an empty paragraph but it never returns true. Why?
var isEmpty = pageChildren[i].outerHTML.toUpperCase() === "<P></P>";
var isSpace = pageChildren[i].outerHTML.toUpperCase() === "<P> </P>";
var isNbsp = pageChildren[i].outerHTML.toUpperCase() === "<P>&NBSP;</P>";
if(!isEmpty && !isSpace && !isNbsp){
//do something
}else{
//do something else
}
This is a copy paste of what IE8 debug tools tells me is in the outerHTML: "<P></P>"
This is being read from an iFrame so i need to remove the <p></p> tags also as the function above this triggers off of the number of children elements in the body of the frame.
Additionally this runs in an HTA application on IE only. The userbase/configuration is highly controlled.
If you’re sure your object is a paragraph, you should use innerHTML instead :
(note that the MDN proposes a replacement for IE8 which lacks trim).
You could also use textContent but the downside is that you have to do a different test for IE.