09/10/2018, 18:14

italic va bold trong textarea

lam sau viết italic hay bold trong textarea , cám ơn các bạn giúp đở .
ttbidouille viết 20:22 ngày 09/10/2018
tim duoc tren net , tham khao .
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 


<HTML> 
<HEAD> 
<TITLE>Editable Regions Sample</TITLE> 


<LINK REL="stylesheet" 
HREF="/workshop/samples/author/dhtml/refs/samplessdkIE4.css" 
TYPE="text/css"> 


<STYLE> 
body{ 
margin:0; 
background:white; 
font-family:verdana; 
font-size:80%; 
} 
.bar{ 
background:#336699; 
width:100%; 
height:30px; 
border-top:1px solid #99CCFF; 
border-bottom:1px solid #000000; 
} 
.desbar{ 
background:#FFFFFF; 
width:100%; 
padding: 10px; 
border-top:1px solid #CCCCCC; 
border-bottom:1px solid #000000; 
color:black; 
font-size:8pt; 
height:105; 
} 
.title{ 
font-size:15pt; 
color:white; 
padding-left:10px; 
} 
PRE { margin:0} 


a:link 
{ 
text-decoration:none; 
color:white 
} 
a:visited 
{ 
text-decoration:none; 
color:white 
} 
a:active 
{ 
text-decoration:none; 
color:white 
} 
a:hover 
{ 
text-decoration:none; 
color:yellow 
} 
BUTTON {cursor:hand; background:#ffffff; border-color:#99ccff; 
font-weight:bold;} 
</STYLE> 



<SCRIPT> 
function fnToggleEdits(oObj,oBtn) { 
currentState = oObj.isContentEditable; 
newState = !currentState; 
oObj.contentEditable = newState; 


newState==false ? oBtn.innerHTML='Editing On' : 
oBtn.innerHTML='Editing Off'; 
} 
</SCRIPT> 


</HEAD> 


<BODY > 
<!-- TOOLBAR_START --><!-- TOOLBAR_EXEMPT --><!-- TOOLBAR_END --> 
<DIV CLASS="bar title"> 
Editable Regions Sample 
</DIV> 
<DIV CLASS="desbar"> 


<div align="center"> 
<DIV UNSELECTABLE ALIGN="center" STYLE="height:210; width:90%; 
background-color:#99CCFF; border:1px solid black"> 
<DIV CLASS="bar title">HTMLEditor (Content Editable DIV)</DIV> 


<DIV style="padding:10px"> 
<BUTTON UNSELECTABLE ID="oEditDiv" TITLE="Editing Off" 
onclick='fnToggleEdits(oDiv,oEditDiv);oDiv.focus();'>Editing Off</BUTTON> 
<BUTTON UNSELECTABLE TITLE="Bold" onclick='if 
(oDiv.isContentEditable==true) document.execCommand("Bold"); oDiv.focus();' 
>Bold</BUTTON> 
<BUTTON UNSELECTABLE TITLE="Italic" onclick='if 
(oDiv.isContentEditable==true) document.execCommand("Italic"); 
oDiv.focus();' ><I>Italic</I></BUTTON> 
<BUTTON UNSELECTABLE TITLE="Underline" onclick='if 
(oDiv.isContentEditable==true) document.execCommand("Underline"); 
oDiv.focus();'><U>Underline</U> </BUTTON> 


</DIV> 
<DIV id=oDiv contenteditable ALIGN=left STYLE="height:100; 
width:95%;background-color:white; font-face:Arial; padding:3; 
border:inset #99ccff; scrollbar-base-color:#99ccff; 
overflow=auto;"></DIV> 
<BUTTON UNSELECTABLE TITLE="Append from HTMLEditor" 
onclick='oTextarea.value+=oDiv.innerHTML;oTextarea.focus();'> 
Append to TextEditor</BUTTON> 


</DIV> 
</div> 
<BR/> 


<BR/><BR/> 
<br> 


<div align="center"> 
<DIV UNSELECTABLE ALIGN="center" STYLE="height:210; width:90%; 
background-color:#99ccff; border:1px solid black"> 
<DIV CLASS="bar title">TEXTEditor (TEXTAREA)</DIV> 


<DIV style="padding:10"> 


<BUTTON UNSELECTABLE ID="oEditText" TITLE="Editing Off" 
onclick='fnToggleEdits(oTextarea,oEditText);oTextarea.focus();'>Editing 
Off</BUTTON> 
</DIV> 


<TEXTAREA id=oTextarea ALIGN=left STYLE="height:100; 
width:95%;background-color:white; padding:3; border:inset #99ccff; 
scrollbar-base-color:#99ccff; overflow=auto;"></TEXTAREA> 
<BR/> 
<BUTTON UNSELECTABLE TITLE="Append to HTMLEditor" 
onclick='oDiv.innerHTML+=oTextarea.value;oTextarea.focus();'> 
Append to HTMLEditor</BUTTON> 
</DIV> 
</div> 
<BR/><P>&nbsp;</DIV> 


<DIV CLASS="bar" STYLE=" padding:5px; padding-left:10"> 
<A href="http://www.microsoft.com/misc/cpyright.htm" target=_top> 
&#169;2000 Microsoft Corporation. All rights reserved. Terms of use</A>. 
</DIV> 
<P><HR><font color="black" face="ms sans serif" size="1">&copy;<a 
href="http://msdn.microsoft.com/isapi/gomscom.asp?TARGET=/misc/cpyright.htm" 
target="_top"> 2000 Microsoft Corporation. All rights reserved. Terms of 
use.</a></font> 
</body> 
</html>
chanhyeu viết 20:15 ngày 09/10/2018
Thực ra chỉ là chèn thêm HTML tag thôi mà bạn.
tulipden viết 20:19 ngày 09/10/2018
<textarea cols='30' rows='10' style='font-weight:bold;font-style:italic'></textarea>
Chỉ cần thế này thôi nè
ttbidouille viết 20:22 ngày 09/10/2018
sau khi có code roi mình viết xong rồi , xem thử maù hay ... trong http://www.tulinh.tk
Bài liên quan
0