到这里看吧,呵呵。
http://www.microsoft.com/china/msdn/workshop/createwp.asp
http://www.microsoft.com/china/msdn/workshop/createwp.asp
解决方案 »
- 怎么学JavaScript
- 如何直接调用流量统计的功能
- 如何捕获 javascript 鼠标在层里的坐标
- checkbox和.....
- 请问如何判断输入的是否为一个数字。
- 请问使屏幕某一区域“上滚”、“下滚”的脚本?
- 为什么我一点击文件连接,文件就中ie中打开了,而不是出现保存对话框???
- 在(netscape)里当鼠标放在图片sys_b_diary.gif上时,怎么才能将图片sys_b_diary.gif换成图片sys_b_diary_on.gif
- Lan=JavaScript:帮我呀~~~~~
- 如何删除INPUT TEXT的以前记录, 没人能解决?
- 如何加入xmlns?
- 如何用JAVA实现更改注册表,就像现在有些网站将机器的默认主页改掉是如何实现的?
http://www.csdn.net/develop/Read_Article.asp?Id=8243execCommand Method
Executes a command on the current document, current selection, or the given range.SyntaxbSuccess = object.execCommand(sCommand [, bUserInterface] [, vValue])
ParameterssCommand
Required. String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script.
bUser
Interface Optional. Boolean that specifies one of the following values:
false Default. Does not display a user interface.
true Displays a user interface, if the command supports one.
vValue
Optional. Variant that specifies the string, number, or other value to assign. Possible values depend on sCommand . Return ValueBoolean that returns one of the following values:true The command was successful.
false The command was not successful. ResDo not invoke the execCommand method until after the page loads.The bUserInterface and vValue parameters may be required depending on the command being executed.Standards InformationThere is no public standard that applies to this method. Applies To document, controlRange, TextRange
也可以是从 document.selection 创建
var oTextRange=document.selection.createRange() //注意这里用createRange不是createTextRange如果整个页面可以编辑 editmode=1 (IE 5以上任何版本) 或者是 页面上某个标记设置成 contentEditable="true" (一般是DIV,此方法需要 IE 5.5或者以上的版本支持)常用的命令集可以到 http://msdn.microsoft.com/workshop/author/dhtml/reference/commandids.asp
查到。。比如说让一个被选择的文字高亮显示:
onmouseup事件:
<script>
function maskText(){
if(document.selection.type=="Text"){
oTextRange=document.selection.createRange();
oTextRange.execCommand("OverWrite","true"); //设置覆盖模式
oTextRange.execCommand("BackColor",true,"#CC0066"); //改变背景颜色
oTextRange.execCommand("ForeColor",true,"#FFFF00"); //改变前景颜色
oTextRange.execCommand("UnSelect"); //取消选择
}
}
document.onmouseup=maskText;
</script>
如果整个页面可以编辑 designmode=1 (IE 5以上任何版本)
那都是偶亲自下橱啊...而不是ctrl+C ctrl+V