<iframe id="MyTitle" width="600" height="400"></iframe>
//复制
function docopy()
{
MyTitle.focus();
MyTitle.document.execCommand("Copy ");
/*实现复制,其中的参数Copy不区分大小写。也可以把这个参数换成Cut,Paste,Delete,JustifyLeft,JustifyCenter,JustifyRight,Bold,Italic,Underline,InsertImage等,这些属性可在上面的属性列表中查找到*/
MyTitle.focus();
}
//另存为
function SaveAs(){
MyTitle.document.execCommand('SaveAs',false,'mycodes.txt');
}
//将选中的区块重设为一个相应的物件
/*
******************************************
* 以下指令都是为选中的区块重设一个object;
* 如没有特殊说明,第二个参数true或false是一样的;
* 参数三表示为该object的id;
* 可以用在javascript中通过其指定的id来控制它
******************************************
*/
/*重设为一个button(InsertButton和InsertInputButtong一样,
只不前者是button,后者是input)*/
MyTitle.document.execCommand('InsertButton',false,"mybutton"); //true或false无效
MyTitle.document.execCommand('InsertFieldSet',true,"myFielt");
//插入一个水平线
MyTitle.document.execCommand('InsertHorizontalRule',true,"myline");
//插入一个iframe
MyTitle.document.execCommand('InsertIFrame',true,"myFrame");
//插入一个InsertImage,设为true时需要图片,false时不需图片
MyTitle.document.execCommand('InsertImage',false,"myPic");
//插入一个checkbox
MyTitle.document.execCommand('InsertInputCheckbox',true,"myCheckBox");
//插入一个file类型的object
MyTitle.document.execCommand('InsertInputFileUpload',false,"myFile");
//插入一个hidden
MyTitle.document.execCommand('InsertInputHidden',false,"myHidden");
//插入一个InputImage
MyTitle.document.execCommand('InsertInputImage',false,"myPutImage");
//插入一个Password
MyTitle.document.execCommand('InsertInputPassword',true,"myPass");
//插入一个Radio
//document.execCommand('InsertInputRadio',false,"myRadio");
//插入一个Reset
MyTitle.document.execCommand('InsertInputReset',true,"myReset");
//插入一个Submit
MyTitle.document.execCommand('InsertInputSubmit',false,"mySubmit");
//插入一个input text
MyTitle.document.execCommand('InsertInputText',false,"myInputText");
//插入一个textarea
MyTitle.document.execCommand('InsertTextArea',true,"myTextarea");
//.插入一个 select list box
MyTitle.document.execCommand('InsertSelectListbox',false,"mySelectList");
//插入一个single select
MyTitle.document.execCommand('InsertSelectDropdown',true,"myDropdown");
//插入一个line break(硬回车??)
MyTitle.document.execCommand('InsertParagraph');
//插入一个marquee
MyTitle.document.execCommand('InsertMarquee',true,"myMa");
//用于取消选中的阴影部分
MyTitle.document.execCommand('Unselect');
//选中页面上的所有元素
MyTitle.document.execCommand('SelectAll');
}
/*
*该function用来将页面保存为一个文件
*/
function SaveAs()
{
//第二个参数为欲保存的文件名
MyTitle.document.execCommand('SaveAs','mycodes.txt');
//打印整个页面
MyTitle.document.execCommand('print');
}
如果要在编辑器中插入Html编码,应该使用如下代码实现:
var reStr="<a href='space.msn.com/user1' target='_blank'>Create by user1@20070725</a>"
MyTitle.document.body.innerHTML += reStr;javascript和多媒体编辑器的实现
[ 本帖最后由 超级用户 于 2007-8-18 12:01 编辑 ] |