Detecting empty in an IFrame

  • Thread starter Thread starter Marcel Balcarek
  • Start date Start date
M

Marcel Balcarek

Hi,

Is there a way in .NET to convert InnerHtml text e.g. '<B>hello</B>' to
'hello' ??

In IE I can use myiframe.innerText to know whether a field is empty, but in
Netscape this method is not available.

myiframe.InnerHTML often has leftover html which converts to nothing in the
iframe (innertext), but is difficult to test for empty.

Any help is appreciated.
Marcel
 
Thanks Chris!

I ended up converting the code to javascript since iframe text is not posted
to the server.

Here are 2 functions I wrote.

Marcel
-----------------------------
function ClearHTMLTags(inHTML) {

var regEx

var outText

// this pattern matches any html tag, g means don't stop after first

regEx = /<[^>]*>/g // or in other languages "<[^>]*>"

// remove any HTML tags

outText = inHTML.replace(regEx, "")

// remove any &nbsp;

regEx = /&nbsp;/g

outText = outText.replace(regEx, "")

// all html tags are stripped

return outText

}

// tests for an empty string - needs javascript1.2

function isStringEmpty(textString)

{

var regexp = / /g // look for any space character and don't stop after first
g

var trimmedTxt = textString.replace(regexp, "") // remove any space
characters

regexp = /\s/g // look for white space \s character and don't stop after
first g

trimmedTxt = trimmedTxt.replace(regexp, "") // remove any white space
characters

if (trimmedTxt.length == 0) {

return true

}

return false

} // end: isStringEmpty()
 
Back
Top