Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Detecting empty in an IFrame

Reply
Thread Tools

Detecting empty in an IFrame

 
 
Marcel Balcarek
Guest
Posts: n/a
 
      12-16-2003
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


 
Reply With Quote
 
 
 
 
Chris Jackson
Guest
Posts: n/a
 
      12-16-2003
Simply remove all HTML tags using regular expression functions, and then
take a look at the remaining string. Here is a sample of clearing tags:

http://www.4guysfromrolla.com/webtech/073000-1.shtml


--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Marcel Balcarek" <(E-Mail Removed)> wrote in message
news:e8eu49%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Marcel Balcarek
Guest
Posts: n/a
 
      12-17-2003
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()


"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
news:e46wkW$(E-Mail Removed)...
> Simply remove all HTML tags using regular expression functions, and then
> take a look at the remaining string. Here is a sample of clearing tags:
>
> http://www.4guysfromrolla.com/webtech/073000-1.shtml
>
>
> --
> Chris Jackson
> Software Engineer
> Microsoft MVP - Windows Client
> Windows XP Associate Expert
> --
> More people read the newsgroups than read my email.
> Reply to the newsgroup for a faster response.
> (Control-G using Outlook Express)
> --
>
> "Marcel Balcarek" <(E-Mail Removed)> wrote in message
> news:e8eu49%(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting an empty line in stdin Albert C Programming 10 01-14-2010 11:27 PM
Detecting empty CheckBoxList without data dbuchanan ASP .Net 3 06-16-2008 02:25 AM
detecting empty 'input type=file' fields? darrel ASP .Net 4 03-22-2005 07:37 PM
Can you help with detecting empty cells in a datagrid ?? Simon Prince ASP .Net 3 01-12-2005 01:40 PM
Get form values from iframe (1) to iframe (2) inside a layer in iframe (1) Daedalous Javascript 3 01-16-2004 11:08 AM



Advertisments