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
>
查看全文
相关阅读:
Java二维数组
Java实现冒泡排序
python类简记
LaTeX:论文Instruction最后一段的章节引用
在Adobe IIIustator中加入数学公式——配合MathType使用
org.springframework.web.bind.annotation不存在
xshell5 下载安装
MultipartFile解析Excel
开源项目环境搭建
学习路线
原文地址:https://www.cnblogs.com/think/p/328907.html
最新文章
win10安装mysql时报错[MY-012576] [InnoDB] Unable to create temporary file; errno: 2
Docker开启ssh服务
screen的简单使用
Vim常用的功能命令
chineseocr项目的配置阶段出现的问题及解决方案
pickle序列化
json序列化
多线程:经典的生产者和消费者问题
文件操作之extract_weapon
文件操作之extract_name
热门文章
time 的用法
正则表达式库RegularExpressionLibrary
多线程2thread
多线程thread
环境变量sys、os模块的使用
jQuery事件绑定,冒泡机制
jQuery选择器简记
轮播图
mysql命令杂记
Java实现杨辉三角
Copyright © 2011-2022 走看看