To bold text using execCommand

by Nirmala 2009-04-20 15:48:19

Hi...
If you want to bold the particular text use the below code

<html>
<head>
<title> Using execCommand to bold text </title>
<script type="text/javascript">
function Init()
{
var edit = document.getElementById("iView").contentWindow.document;
edit.designMode = "On" ;
}
function boldIt()
{
var edit = document.getElementById("iView").contentWindow;
edit.focus();
edit.document.execCommand("bold", false, "");
edit.focus();
}
</script>
<body onLoad="Init()">
<iframe id="iView" style="width: 200px; height:70px"></iframe>
<input type="button" onClick="boldIt()" value="Bold Text">
</body>
</html>

Tagged in:

2876
like
1
dislike
0
mail
flag

You must LOGIN to add comments