<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
</HEAD> <BODY> <p>test string</p>
 <br> <input type="button" value="bold" name="setBold" onclick="setBold()"/>
 
<div id="contain" style="width:300px;height:20px;position:absolute">
<div id="textEdit" style="width:50px;height:auto;position:absolute;background-color:red" CONTENTEDITABLE>
</div>
</div>
<script type="text/javascript">function setBold()
{
    var selectText = document.selection.createRange();
    if(selectText.text != '')
    {
        selectText.execCommand("bold");
alert(document.getElementById('textEdit').innerHTML)//STRONG
    }
    else
    {
        alert('noselect');
    }
}</script> </BODY>
</HTML>