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
>
查看全文
相关阅读:
lightoj 1094 Farthest Nodes in a Tree 【树的直径 裸题】
nyoj 1185 最大最小值【线段树最大值最小值维护】
nyoj 123 士兵杀敌(四) 树状数组【单点查询+区间修改】
poj 3468 A Simple Problem with Integers【线段树区间修改】
hdoj 1698 Just a Hook【线段树区间修改】
hdoj 1556 Color the ball【线段树区间更新】
hdoj 1286 找新朋友【欧拉函数】
[LC] 303. Range Sum Query
[LC] 79. Word Search
[LC] 211. Add and Search Word
原文地址:https://www.cnblogs.com/think/p/328907.html
最新文章
E
F
Almost Regular Bracket Sequence CodeForces
Successor HDU
Sereja and Brackets CodeForces
Sereja and Brackets CodeForces
The Preliminary Contest for ICPC Asia Nanjing 2019 B. super_log (广义欧拉降幂)
[kuangbin带你飞]专题一 简单搜索
Linux shell命令特殊符号
VMware Tools安装并共享文件夹设置
热门文章
关于最长公共子序列(SIM核心算法)
Apache
linux下程序的编译和链接
ubantu命令积累
HUSTOJ搭建执行(LAMP+hustoj+myphpadmin)
VMware下安装Ubuntu16.10(全屏)
[Linux/Ubuntu] vi/vim 使用方法讲解
hdoj 2401 Baskets of Gold Coins
hdoj 1787 GCD Again【欧拉函数】
hdoj 1541 Stars【线段树单点更新+最大值维护】
Copyright © 2011-2022 走看看