- ·上一篇内容:document.all.WebBrowser.ExecWB()方法介绍
- ·下一篇内容:如何解决Flash挡住层的问题
document.execCommand()方法介绍
下面给出一些具体的例子:
-
- //相当于单击文件中的打开按钮
- document.execCommand("Open");
- //将当前页面另存为
- document.execCommand("SaveAs");
- //剪贴选中的文字到剪贴板;
- document.execCommand("Cut","false",null);
- //删除选中的文字;
- document.execCommand("Delete","false",null);
- //改变选中区域的字体;
- document.execCommand("FontName","false",sFontName);
- //改变选中区域的字体大小;
- document.execCommand("FontSize","false",sSize|iSize);
- //设置前景颜色;
- document.execCommand("ForeColor","false",sColor);
- //使绝对定位的对象可直接拖动;
- document.execCommand("2D-Position","false","true");
- //使对象定位变成绝对定位;
- document.execCommand("AbsolutePosition","false","true");
- //设置背景颜色;
- document.execCommand("BackColor","false",sColor);
- //使选中区域的文字加粗;
- document.execCommand("Bold","false",null);
- //复制选中的文字到剪贴板;
- document.execCommand("Copy","false",null);
- //设置指定锚点为书签;
- document.execCommand("CreateBookmark","false",sAnchorName);
- //将选中文本变成超连接,若第二个参数为true,会出现参数设置对话框;
- document.execCommand("CreateLink","false",sLinkURL);
- //设置当前块的标签名;
- document.execCommand("FormatBlock","false",sTagName);
本文源自:翔宇亭——IT乐园(http://www.biye5u.com),转载请保留此信息!
微信搜索“优雅的代码”关注本站的公众号,或直接使用微信扫描下面二维码关注本站公众号,以获取最新内容。
个人成长离不开各位的关注,你的关注就是我继续前行的动力。