Detecting empty in an IFrame

Discussion in 'ASP .Net' started by Marcel Balcarek, Dec 16, 2003.

  1. 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
    Marcel Balcarek, Dec 16, 2003
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:e8eu49%...
    > 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
    >
    >
    Chris Jackson, Dec 16, 2003
    #2
    1. Advertising

  3. 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$...
    > 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" <> wrote in message
    > news:e8eu49%...
    > > 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
    > >
    > >

    >
    >
    Marcel Balcarek, Dec 17, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Prince
    Replies:
    3
    Views:
    2,717
    Eliyahu Goldin
    Jan 12, 2005
  2. darrel
    Replies:
    4
    Views:
    4,094
    darrel
    Mar 22, 2005
  3. dbuchanan
    Replies:
    3
    Views:
    1,767
    Steven Cheng [MSFT]
    Jun 16, 2008
  4. Albert

    Detecting an empty line in stdin

    Albert, Jan 13, 2010, in forum: C Programming
    Replies:
    10
    Views:
    1,943
    Ike Naar
    Jan 14, 2010
  5. Daedalous
    Replies:
    3
    Views:
    658
    Daedalous
    Jan 16, 2004
Loading...

Share This Page