Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3336056
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:05:26+00:00 2026-05-18T00:05:26+00:00

I’m trying to replicate the functionality of facebook’s status update where tags within the

  • 0

I’m trying to replicate the functionality of facebook’s status update where tags within the post are highlighted. E.g, you hit the ‘@’ character, and autocomplete to a page you are a fan of, and then that tagged piece of the text is highlighted even as you continue to type.

After digging into the dom, it looks like they pull this off similar to the technique recommended by this previous answer: overlaying an absolutely positioned div atop a text area with the tag surrounded by <b> and css to highlight the <b> tags within the overlay. A crucial tweak they add is to use color:transparent on the overlay so that only the highlight shows up.

alt text

This avoids the ugly darkening of the text being written on top of itself. Notice that without this rule (when I disable it in the dom inspector in chrome), facebook’s update bar has the double text effect:

alt text

So far so good, but what I’m running into now is that color:transparent isn’t supported in ie, so the ugly double text effect is there. I looked at the status update box in ie8 and facebook seems to get around this, but the developer tools aren’t powerful enough to inspect the dom and see what they are doing (css inspection seems to be broken for that page).

Here’s what I have so far, looking good in chrome:

alt text

and bad with the double text in IE8:

alt text

Any ideas? And please, keep suggestions to the specific overlay technique, I know I could try to use some big honking iframe embedding rich text editor, but this is really a simple enhancement that is only going to apply to a couple lines of text at most.

Full code below.

html:

        <div class="textarea textareaBorder">
            <textarea id="myTextarea" class="textarea realTextarea"></textarea>
            <div id="myOtherTextarea" class="textarea overlayTextarea"></div>
        </div>

css:

.textarea {
    font-family:monospace;
    font-size: 12px;
    border: 0;
    width: 100%;
    height: 200px;
}

.realTextarea {
    margin: 0;
    background: transparent;
    position: absolute;
    z-index: 999;
}

.overlayTextarea {
    margin: 0;
    position: absolute;
    color:transparent;
    top: 1px;
    left: 1px;
    z-index: 998;
}

.overlayTextarea b {
    background:#add8e6;
}

.textareaBorder {
    border: groove 1px #ccc;
    position: relative;
    width: 702px;
    height: 202px;
}

javascript:

$("textarea.realTextarea").keyup(function(e) {
    var textval = $(e.target).val();
    var markedup = textval.replace(/(the magic word)/g, "<b>$1</b>")

    $("#myOtherTextarea").html(markedup);
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:05:26+00:00Added an answer on May 18, 2026 at 12:05 am

    To work around the lack of transparent color on IE, you can put the highlighted text and its surroundings inside additional <span> elements, force their opacity to zero using a filter, and keep the background color on the <b> element.

    Of course, the <span> elements need to have layout for the filter to work, and setting their display property to inline-block will mess with whitespace, so you need to compensate for that by setting their white-space property to pre.

    CSS:

    .overlayTextarea b {
        background: #add8e6;
    }
    
    .overlayTextarea span {
        filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
        display: inline-block;
        white-space: pre;
    }
    

    Javascript:

    $("textarea.realTextarea").keyup(function(e) {
        var textval = $(e.target).val();
        var markedup = textval.replace(/(.*)(the magic word)(.*)/g,
            "<span>$1</span><b><span>$2</span></b><span>$3</span>");
        $("#myOtherTextarea").html(markedup);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.