Detecting empty in an IFrame

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
 
M

Marcel Balcarek

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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top