zoukankan
html css js c++ java
在光标处添加文字,或对选择的文字进行更改(JS:TextRange)
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
>
<
title
>
Untitled Page
</
title
>
<
script
language
="javascript"
type
="text/javascript"
>
function
Blod()
{
Format(
"
粗体
"
,
"
'''
"
);
}
function
Italic()
{
Format(
"
斜体
"
,
"
''
"
);
}
function
Format(formatName,format)
{
var
textarea
=
document.getElementById(
"
txaContent
"
);
if
(textarea.pos
!=
null
)
{
var
s
=
textarea.pos.text;
if
(s
==
null
||
s
==
'undefined'
||
s
==
'')
{
s
=
formatName ;
}
s
=
format
+
s
+
format;
textarea.pos.text
=
s;
}
else
{
textarea.value
+=
format
+
formatName
+
format;
}
}
</
script
>
</
head
>
<
body
>
<
textarea
id
="txaContent"
cols
="20"
rows
="20"
onselect
="this.pos = document.selection.createRange();"
onclick
="this.pos = document.selection.createRange();"
onkeyup
="this.pos = document.selection.createRange();"
></
textarea
>
<
input
type
="button"
onclick
="Blod()"
value
="Blod"
id
="btnBlod"
/>
<
input
type
="button"
onclick
="Italic()"
value
="Italic"
id
="btnItalic"
/>
</
body
>
</
html
>
查看全文
相关阅读:
项目Alpha冲刺(团队)-第七天冲刺
NOIP模拟赛[补档]
关于补档
noip2017集训测试赛(三) Problem B: mex [补档]
初赛准备 [补档]
记录 [补档]
Leave It Behind and Carry On ---- 高一下期末考反思 [补档]
NOIP 2017 赛后反思 [补档]
囤题 [补档]
组合游戏学习笔记 [补档]
原文地址:https://www.cnblogs.com/think/p/328907.html
最新文章
Alpha冲刺(9/10)——追光的人
Alpha冲刺(8/10)——追光的人
测试报告——追光的人
Alpha冲刺(7/10)——追光的人
项目Beta冲刺Day1
凡事预则立
事后诸葛亮
项目Alpha冲刺总结随笔
项目Alpha冲刺(10/10)
项目Alpha冲刺(9/10)
热门文章
项目Alpha冲刺(8/10)
项目Alpha冲刺(7/10)
项目Alpha冲刺(6/10)
项目Beta冲刺(团队)——凡事预则立
事后诸葛亮(团队)
项目Alpha冲刺(团队)-总结篇
项目Alpha冲刺(团队)-测试篇
项目Alpha冲刺(团队)-第十天冲刺
项目Alpha冲刺(团队)-第九天冲刺
项目Alpha冲刺(团队)-第八天冲刺
Copyright © 2011-2022 走看看