分享
 
 
 

JavaScript-execCommand指令集

王朝学院·作者佚名  2010-08-09
窄屏简体版  字體: |||超大  

<HTML>

<HEAD>

<TITLE>javaScript--execCommand指令集</TITLE>

<SCRIPT LANGUAGE="Javascript">

/*

* 该function执行copy指令

*/

document.execCommand("BackgroundImageCache", false, true);

function fn_doufucopy(){

edit.select();

document.execCommand('Copy');

}

/*

* 该function执行paste指令

*/

function fn_doufupaste(){

tt.focus();

document.execCommand('paste');

}

/*

* 该function用来创建一个超链接

*/

function fn_creatlink() {

document.execCommand('CreateLink',true,'true');//弹出一个对话框输入URL

//document.execCommand('CreateLink',false,'http://www.51cto.com');

}

/*

* 该function用来将选中的区块设为指定的背景色

*/

function fn_change_backcolor(){

document.execCommand('BackColor',true,'#FFbbDD');//true或false都可以

}

/*

* 该function用来将选中的区块设为指定的前景色,改变选中区块的字体大小,改变字体,字体变粗变斜

*/

function fn_change_forecolor(){

//指定前景色

document.execCommand('ForeColor',false,'#BBDDCC');//true或false都可以

//指定背景色

document.execCommand('FontSize',false,7); //true或false都可以

//字体必须是系统支持的字体

document.execCommand('FontName',false,'标楷体'); //true或false都可以

//字体变粗

document.execCommand('Bold');

//变斜体

document.execCommand('Italic');

}

http://www.devdao.com/

/*

* 该function用来将选中的区块加上不同的线条

*/

function fn_change_selection(){

//将选中的文字加下划线

document.execCommand('Underline');

//在选中的文字上划粗线

document.execCommand('StrikeThrough');

//将选中的部分文字变细

document.execCommand('SuperScript');

//将选中区块的下划线取消掉

document.execCommand('Underline');

}

/*

* 该function用来将选中的区块排成不同的格式

*/

function fn_format(){

//有序列排列

document.execCommand('InsertOrderedList');

//实心无序列排列

document.execCommand('InsertUnorderedList');

//空心无序列排列

document.execCommand('Indent');

}

/*

* 该function用来将选中的区块剪下或是删除掉

*/

function fn_CutOrDel(){

//删除选中的区块

//document.execCommand('Delete');

//剪下选中的区块

document.execCommand('Cut');

}

/*

* 该function用来将选中的区块重设为一个相应的物件

*/

function fn_InsObj(){

/*

******************************************

* 以下指令都是为选中的区块重设一个object;

* 如没有特殊说明,第二个参数true或false是一样的;

* 参数三表示为该object的id;

* 可以用在javascript中通过其指定的id来控制它

******************************************

*/

/*重设为一个button(InsertButton和InsertInputButtong一样, 只不前者是button,后者是input)*/

/*

document.execCommand('InsertButton',false,"aa"); //true或false无效

document.all.aa.value="风舞九天";

*/

//重设为一个fieldset

/*

document.execCommand('InsertFieldSet',true,"aa");

document.all.aa.innerText="刀剑如梦";

*/

//插入一个水平线

//document.execCommand('InsertHorizontalRule',true,"aa");

//插入一个iframe

//document.execCommand('InsertIFrame',true,"aa");

//插入一个InsertImage,设为true时需要图片,false时不需图片

//document.execCommand('InsertImage',false,"aa");

//插入一个checkbox

//document.execCommand('InsertInputCheckbox',true,"aa");

//插入一个file类型的object

//document.execCommand('InsertInputFileUpload',false,"aa");

//插入一个hidden

/*

document.execCommand('InsertInputHidden',false,"aa");

alert(document.all.aa.id);

*/

//插入一个InputImage

/*

document.execCommand('InsertInputImage',false,"aa");

document.all.aa.src="F-a10.gif";*/

//插入一个PassWord

//document.execCommand('InsertInputPassword',true,"aa");

//插入一个Radio

//document.execCommand('InsertInputRadio',false,"aa");

//插入一个Reset

//document.execCommand('InsertInputReset',true,"aa");

//插入一个Submit

//document.execCommand('InsertInputSubmit',false,"aa");

//插入一个input text

//document.execCommand('InsertInputText',false,"aa");

//插入一个textarea

//document.execCommand('InsertTextArea',true,"aa");

//插入一个 select list box

//document.execCommand('InsertSelectListbox',false,"aa");

//插入一个single select

document.execCommand('InsertSelectDropdown',true,"aa");

//插入一个line break(硬回车??)

//document.execCommand('InsertParagraph');

//插入一个marquee

/*document.execCommand('InsertMarquee',true,"aa");

document.all.aa.innerText="bbbbb";*/

//用于取消选中的阴影部分

//document.execCommand('Unselect');

//选中页面上的所有元素

//document.execCommand('SelectAll');

}

/*

*该function用来将页面保存为一个文件

*/

function fn_save(){

//第二个参数为欲保存的文件名

document.execCommand('SaveAs','mycodes.txt');

//打印整个页面

//document.execCommand('PRint');

}

</SCRIPT>

</HEAD>

<body>

<input id="edit" value="范例" NAME="edit"><br>

<button ID="Button1">Copy</button> <button ID="Button2">

paste</button><br>

<textarea id="tt" rows="10" cols="50" NAME="tt"></textarea>

<hr>

<br>

浮沉聚散变化又再,但是总可卷土重来.<br>

天若有情天亦老,人间正道是沧桑.<br>

都怪我,太执着,却也等不到花开叶落.<br>

<br>

Please select above letters, then click following buttons:<br>

<hr>

<input type="button" value="创建CreateLink" ID="Button3" NAME="Button3"><br>

<input type="button" value="改变文字背景色" ID="Button4" NAME="Button4"><br>

<input type="button" value="改变文字前景色" ID="Button5" NAME="Button5"><br>

<input type="button" value="给文字加线条" ID="Button6" NAME="Button6"><br>

<input type="button" value="改变文字的排列" ID="Button7" NAME="Button7"><br>

<input type="button" value="删除或剪下选中的部分" ID="Button8" NAME="Button8"><br>

<input type="button" value="插入Object" ID="Button9" NAME="Button9"><br>

<input type="button" value="保存或打印文件" ID="Button10" NAME="Button10"><br>

<input type="button" value="Refresh属性" onclick="document.execCommand('Refresh')" ID="Button11" NAME="Button11">

</body>

</HTML>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有