发新话题
打印

[新鲜发布] 在光标处添加文字,或对选择的文字进行更改(JS:TextRange)

在光标处添加文字,或对选择的文字进行更改(JS:TextRange)

查看数: 72 回复数: 3 最新回复

与好友共享:

内容简介:点击关闭

Copy语言代码:!DOCTYPEhtmlPUBLIC-//W3C//DTDXHTML1.0Transitional//ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
...
Copy
语言代码:
<!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="javascripttype="text/javascript">
    function 
Blod()
    {
        
Format("粗体","'''");
    }
    function 
Italic()
    {
        
Format("斜体","''");
    }
    function 
Format(formatName,format)
    {        
        var 
textarea document.getElementById("txaContent");
        if(
textarea.pos != null)
        {
            var 
textarea.pos.text;
            if(
== null || == 'undefined'||== '')
            {
                
formatName ;
            }
            
format 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>
你现在是游客:请登录或者注册

搜索更多相关主题的帖子: 光标 TextRange 文字 选择

Rojo google reader netvibes 哪吒 抓虾 my yahoo Feedsky FEED 订阅
作者: Yuan 主题: 在光标处添加文字,或对选择的文字进行更改(JS: ... 时间: 2008-11-4 16:09

TOP

最新网站秀: (还等什么?马上加入我们吧! 快速加入

 华中师范大  盱眙吧1  南邮风云   夜族网游公  在日中华情  生活大家坛  智商250  塞班智能手  论剑社区  潮州论坛  灵下异度  封开家园 
用户正在观看: 热门标签
美女人体艺术绝
杀破狼
樱之炫视频教程——五
雨儿短裙热舞
情圣【国语中字】DV
作品源自网络,请支持正版


HEY HEY HE


[ほんじゃに!Hon


[ほんじゃに!Hon


HEY3 关8
发新话题