日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

用Twebbrowser做可控编辑器与MSHTML

發(fā)布時間:2024/9/20 HTML 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用Twebbrowser做可控编辑器与MSHTML 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

首先要明白mshtml的屬性方法:

{IHTMLDocument2 方法:} write //寫入 writeln //寫入并換行 open //打開一個流,以收集 document.write 或 document.writeln 的輸出 close //關(guān)閉并輸出用 document.open 方法打開的流 clear //清空文檔中所有元素, 可能暫時不支持 queryCommandSupported //是否支持指定命令 queryCommandEnabled //指定命令是否有效 queryCommandState //是否設(shè)置了指定命令 queryCommandIndeterm //指定命令是否處于不確定狀態(tài) queryCommandText //命令 queryCommandValue //命令值 execCommand //執(zhí)行命令 execCommandShowHelp //命令幫助信息 createElement //建立元素 elementFromPoint //指定坐標下的元素 createStyleSheet //創(chuàng)建一個樣式表{IHTMLDocument2 屬性:} all //所有 HTML 元素的集合 images //所有 image 對象的集合 applets //所有 applet 對象的集合 links //所有 link 對象的集合 forms //所有 form 對象的集合 anchors //所有 anchor 對象的集合 scripts //所有 script 對象的集合 frames //所有 frame 對象的集合, 這應(yīng)該和 window.frames 是一樣的 embeds //所有 embed 對象的集合 plugins //所有 plugin 對象的集合 styleSheets //樣式表集合 title //網(wǎng)頁標題 body //body 對象 activeElement //當前具有輸入焦點的元素 designMode //設(shè)計模式, 可選值: Inherit On Off selection //當前選擇 readyState //頁面讀取狀態(tài): uninitialized、loading、loaded、interactive、completed linkColor //鏈接的顏色 alinkColor //活動鏈接的顏色 vlinkColor //已訪問過的鏈接的顏色 bgColor //背景顏色 fgColor //文本顏色 referrer //返回載入當前頁面的頁面的 URL location //同 window.location lastModified //返回文檔最后修改的日期和時間 url //返回當前文檔的 URL domain //返回域名 cookie //返回文檔相關(guān)的 cookie expando //可設(shè)置與獲取的布爾值, 是否允許擴展 charset //獲取文檔的字符集名稱 defaultCharset //獲取瀏覽器默認的字符集名稱 mimeType //文檔類型 fileSize //文檔大小, 單位字節(jié), 用字符串表示 fileCreatedDate //文檔建立時間 ??? fileModifiedDate //文檔修改時間 ??? fileUpdatedDate //文檔更新時間 ??? security //文檔安全 protocol //傳輸協(xié)議 nameProp //文件標題, 好像同 Title parentWindow //父窗口 Script //{IHTMLDocument2 事件:} onhelp //用 F1 獲取幫助時 onclick //單擊時 ondblclick //雙擊時 onmousedown //鼠標點下時 onmouseup //鼠標抬起時 onmousemove //鼠標移動時 onmouseover //鼠標進入時 onmouseout //鼠標離開時 onkeypress //按鍵時 onkeyup //鍵按住時 onkeydown //鍵抬起時 onreadystatechange //狀態(tài)改變時 onrowexit //當前數(shù)據(jù)源的數(shù)據(jù)將要發(fā)生變化時 onrowenter //當前數(shù)據(jù)源的數(shù)據(jù)發(fā)生變化并且有新的數(shù)據(jù)時 ondragstart //開始拖動時 onselectstart //開始選擇時 onbeforeupdate //更新前 onafterupdate //更新后 onerrorupdate //更新錯誤時{IHTMLDocument3 方法:} recalc //重新獲取文檔中的全部動態(tài)屬性 releaseCapture //釋放文檔中對象的鼠標捕捉{IHTMLDocument3 屬性:} createTextNode //建立文本 attachEvent //綁定事件 detachEvent //取消事件綁定 createDocumentFragment//創(chuàng)建新文檔 getElementsByName //返回帶有指定 name 的對象集合 getElementById //返回指定 id 的第一個對象的引用 getElementsByTagName //返回指定標簽的對象集合 documentElement //獲取文檔根部節(jié)點, 也就是 HTML 節(jié)點 uniqueID //獲取對象的唯一標識符 dir // parentDocument // enableDownload baseUrl //基礎(chǔ)地址{IHTMLDocument3 事件:} onrowsdelete //當前數(shù)據(jù)記錄被刪除時 onrowsinserted //當前數(shù)據(jù)源將要插入新數(shù)據(jù)時 oncellchange //當數(shù)據(jù)來源發(fā)生變化時 ondatasetchanged //數(shù)據(jù)源發(fā)生變化時 ondataavailable //當數(shù)據(jù)接收完成時 ondatasetcomplete //當數(shù)據(jù)源的全部有效數(shù)據(jù)讀取完畢時 onpropertychange //改變屬性時 oncontextmenu //當按下鼠標右鍵出現(xiàn)菜單或通過鍵盤觸發(fā)頁面菜單時 onstop //停止或離開時{IHTMLDocument4 方法:} focus //獲得輸入焦點 hasFocus //是否擁有輸入焦點 createDocumentFromUrl //下載指定網(wǎng)頁并返回其 IHTMLDocument2 接口 CreateEventObject //生成當使用 fireEvent 方法時用于傳遞事件相關(guān)信息的 event 對象 ??? FireEvent{IHTMLDocument4 屬性:} createRenderStyle //建立 IHTMLRenderStyle 接口 namespaces // media // URLUnencoded //獲取去除字符編碼的 URL{IHTMLDocument4 事件:} onselectionchange //改變選擇時 oncontrolselect //好像是框選時{IHTMLDocument5 方法:} createAttribute //建立指定 name 的屬性 createComment //建立注釋{IHTMLDocument5 屬性:} doctype //文檔類型 implementation_ //獲取 IHTMLDOMImplementation 接口 compatMode //兼容模式, 返回 BackCompat、CSS1Compat 等{IHTMLDocument5 事件:} onmousewheel //旋轉(zhuǎn)鼠標滾動輪時 onfocusin //獲取輸入焦點時 onfocusout //失去輸入焦點時 onactivate //激活時 ondeactivate //當前對象變?yōu)楦肝臋n的其他對象時 onbeforeactivate //onactivate 前 onbeforedeactivate //ondeactivate 前 Ihtmldocument2接口的使用 MSHTML是微軟公司的一個COM組件,該組件封裝了HTML語言中的所有元素及其屬性,通過其提供的標準接口,可以訪問指定網(wǎng)頁的所有元素.MSHTML對象模型是由一些對象和集合組成的.處于根部的是HTML,描述了打開頁面的1個窗口,包括一系列集合和對象。如Frames集合,History,Location,Navigator,Document,Vi—sum,Event對象等.其中描述呈現(xiàn)在客戶窗口實際網(wǎng)頁的是Document對象。由一系列的屬性、方法、對象和集合組成.其中All集合中包含網(wǎng)頁中所有標記(Tag)元素,其主要的方法和屬性有:(1)Length(長度):即標記出現(xiàn)的個數(shù),可以把標記的集合理解為從0開始的一維數(shù)組,其次序按照標記在網(wǎng)頁位置排列;(2)Tags(標記):用于過濾出給定標記的集合,如Doc.Al1.Tags(P)得到所有分段標記P;(3)Item(項目):用于選擇集合中的某1個元素,如object.item(0)得到集合的第1個元素,而object.item(i)得到第i+1個元素.此外,IHTMLElement也是個常用的集合對象,代表網(wǎng)頁中指定標記的集合,通過這個集合對象,可以得到網(wǎng)頁上特定標記的內(nèi)容.IHTMLElement有4個主要屬性:(1)InnerText:開始標記和結(jié)束標記之間的文本;(2)InnerHTML:開始標記和結(jié)束標記之間的文本和HTML;(3)OuterText:對象的文本;(4)OuterHTML:對象的文本和HTML. 注意:使用前加入單元mshtml 演示表單提交 procedure TForm1.Button1Click(Sender: TObject); var Doc:IHTMLDocument2; input:OleVariant; userinputelement,pwdinputelement:ihtmlinputelement; begin doc:=webbrowser1.document as ihtmldocument2; userinputelement:=(doc.all.item('user'(也就是網(wǎng)頁中用戶名控件的名字),0) as ihtmlinputelement); userinputelement.value:=edit1.text;(也就是你要向網(wǎng)頁輸入的東西) pwdinputelement:=(doc.all.item('password',0) as ihtmlinputelement); pwdinputelement.value:=edit2.text; input:=doc.all.item('submit',0); input.click; end; 當提交數(shù)據(jù)按鈕沒有NAME屬性時,采用如下方法: procedure TForm1.Button1Click(Sender: TObject); var Doc:IHTMLDocument2; form:ithmlformelement; userinputelement,pwdinputelement:ihtmlinputelement; begin doc:=webbrowser1.document as ihtmldocument2; userinputelement:=(doc.all.item('user'(也就是網(wǎng)頁中用戶名控件的名字),0) as ihtmlinputelement); userinputelement.value:=edit1.text;(也就是你要向網(wǎng)頁輸入的東西) pwdinputelement:=(doc.all.item('password',0) as ihtmlinputelement); pwdinputelement:=edit2.text; form:=(doc.all.item('login_form',0) as ihtmlformelement): form.submit; end; 登錄"按鈕一般都是網(wǎng)頁中默認的回車按鈕,所以可以用上面代碼來代替前面的點擊按鈕 讀取某網(wǎng)頁內(nèi)容 在創(chuàng)建窗體的時候打開一網(wǎng)頁webbrowser1.navigate('http://www.baidu.com') procedure TForm1.Button1Click(Sender: TObject); begin memo1.lines.add(ihtmldocument2(webbrowser1.document).body.outerhtml); end;這樣一來memo1中顯示www.baidu.com的html 利用webbrowser1控件瀏覽某txt中文件的內(nèi)容,并以html形式來顯示出來 在webbrowser1的控件中的ondocumentcomplete事件加入如下代碼 procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant); var webdoc:htmldocument ; webbody:htmlbody; begin webdoc:=webbrowser1.document as htmldocument; webbody:=webdoc.body as htmlbody; webbody.insertAdjacentHTML('beforeend','<form method="POST" action="">'); webbody.insertAdjacentHTML('beforeend','Password: '); webbody.insertAdjacentHTML('beforeend','<input type="password" >'); webbody.insertAdjacentHTML('beforeend','<input type="submit" value="LOGIN" >'); webbody.insertAdjacentHTML('beforeend',' '); webbody.insertAdjacentHTML('beforeend','</form>'); end;讀取的時候,webbrowser控件得要完整的打開某一網(wǎng)頁, View Code

把上面相關(guān)資料搞明白,事情就會簡單很多。

1、希望只有部分內(nèi)容可以編輯:注意【contentEditable=true】的使用:

<BODY ><P contentEditable=true>USEGEAR(只有這里可以編輯)</p> <P>&nbsp;</P> <P>&nbsp;</P> <P>68767896897</P> <P>&nbsp;</P> <P>yutyuty</P> <P>&nbsp;</P></BODY>

2、希望在可編輯區(qū)光標處插入html文本or其他

((WebBrowser1.Documentas IHTMLDocument2).selection.createRange as IHtmlTxtRange).pasteHTML('hello usegear!');

3、html文件中有關(guān)圖像文件的處理
 由于編輯結(jié)果是一個html文件,需要如同word文檔帶上圖像的一個文件,而不可能還有個單獨圖像文件 ,所以把圖像文件轉(zhuǎn)成base64的文本放在html中

  • uses EncdDecd;//d自帶的單元,就不要到處找了
  • =======================
  • var
  • myStringStream : TStringStream;
  • myStream :TStream;
  • ===================
  • StringStream := TStringStream.Create('');
  • myStream := TFileStream.Create('f:\QQ圖片20170923175727.png',fmOpenRead);
  • EncdDecd.EncodeStream(myStream,myStringStream);
  • mmo1.Text :='<img contentEditable="true" src="https://img-blog.csdnimg.cn/2022010703261735164.png' + myStringStream.DataString +'"</img >';
  • ((WebBrowser1.Document as IHTMLDocument2).selection.createRange as IHtmlTxtRange).pasteHTML(mmo1.Text);
  • 4、其他的編輯功能,網(wǎng)上很多。

  • ///網(wǎng)頁查看模式
  • (WebBrowser1.Document as IHTMLDocument2).designMode := 'on';
  • (WebBrowser1.Document as IHTMLDocument2).execCommand('EditMode',False,1);
  • ///網(wǎng)頁編輯模式
  • (WebBrowser1.Document as IHTMLDocument2).designMode := 'off';
  • (WebBrowser1.Document as IHTMLDocument2).execCommand('BrowseMode',False,1);
  • ///選中文本編輯
  • ///設(shè)置字體
  • //名稱 (WebBrowser1.Document as IHTMLDocument2).execCommand('FontName', False, '宋體');
  • //大小 (WebBrowser1.Document as IHTMLDocument2).execCommand('FontSize', False, 7);///字體大小是從1到7
  • 樣式
  • //粗體 (WebBrowser1.Document as IHTMLDocument2).execCommand('Bold', False, 1);
  • //斜體 (WebBrowser1.Document as IHTMLDocument2).execCommand('Italic', False, 1);
  • /下劃線 (WebBrowser1.Document as IHTMLDocument2).execCommand('Underline', False, 1);
  • /刪除線 (WebBrowser1.Document as IHTMLDocument2).execCommand('StrikeThrough', False, 1);
  • ///超鏈接 (WebBrowser1.Document as IHTMLDocument2).execCommand('CreateLink', False, 1);
  • ///刪除超鏈接 (WebBrowser1.Document as IHTMLDocument2).execCommand('UnLink', False, 1);
  • ///設(shè)置
  • ///設(shè)置文字前景色 (WebBrowser1.Document as IHTMLDocument2).execCommand('ForeColor',False, 'Red');
  • ///設(shè)置文字背景色 (WebBrowser1.Document as IHTMLDocument2).execCommand('BackColor',False, 'Blue');
  • ///設(shè)置下標 (WebBrowser1.Document as Ihtmldocument2).execCommand('SubScript',False,1);
  • ///設(shè)置上標 (WebBrowser1.Document as Ihtmldocument2).execCommand('SuperScript',False,1);
  • ///設(shè)置對齊方式
  • ///設(shè)置左對齊 (WebBrowser1.Document as IHTMLDocument2).execCommand('JustifyLeft', False, 0);
  • ///設(shè)置中對齊 (WebBrowser1.Document as IHTMLDocument2).execCommand('JustifyCenter', False, 0);
  • ///設(shè)置右對齊 (WebBrowser1.Document as IHTMLDocument2).execCommand('JustifyRight', False, 0);
  • ///設(shè)置兩端對齊 (WebBrowser1.Document as IHTMLDocument2).execCommand('JustifyFull', False, 0);
  • ///縮進
  • /// 向右縮進 (WebBrowser1.Document as Ihtmldocument2).execCommand('Indent',True,1);
  • /// 向左縮進 (WebBrowser1.Document as Ihtmldocument2).execCommand('Outdent',True,1);
  • ///清除格式 (WebBrowser1.Document as Ihtmldocument2).execCommand('Removeformat',True,0);
  • ///序列查看
  • /// 數(shù)字格式 (WebBrowser1.Document as Ihtmldocument2).execCommand('InsertOrderedList',True,0);
  • /// 圓點查看 (WebBrowser1.Document as Ihtmldocument2).execCommand('InsertUnorderedList',True,0);
  • ///插入圖片(靜態(tài)) (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertImage', True, '');
  • (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertImage', False, 'C:\1.png');
  • ///插入HTML組件
  • ///后面的字符串為這個控件的ID號
  • ///直線 Line (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertHorizontalRule', True, '');
  • ///按鈕 Button (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertButton', True, '');
  • ///復(fù)選框 CheckBox (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertInputCheckbox', True, '');
  • ///單選框 Radio (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertInputRadio', True, '');
  • ///編輯框 Edit (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertInputText', True, '');
  • ///文本框 Memo (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertTextArea', True, '');
  • ///密碼框 PswEdit (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertInputPassword', True, '');
  • ///組框架 GroupBox (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertIFrame', True, '');
  • ///列表框 ListBox (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertSelectListbox', True, '');
  • ///組合框 Combobox (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertSelectDropdown', True, '');
    document.execCommand()方法處理Html數(shù)據(jù)時常用語法格式 如下:
    復(fù)制內(nèi)容到剪貼板
    代碼 :
    document.execCommand(sCommand[,交互方式, 動態(tài)參數(shù) ])
    其中:sCommand為指令參數(shù)(如下例中的"2D-Position"),交互方式參數(shù)如果是true的話將顯示對話框,如果為false的話,則不顯示對話框(下例中的"false"即表示不顯示對話框),動態(tài)參數(shù)一般為一可用值或?qū)傩?值(如下例中的"true")。
    document.execCommand("2D-Position","false","true");
    調(diào)用execCommand()可以實現(xiàn)瀏覽器菜單 的很多功能. 如保存文件 ,打開新文件,撤消、重做操作...等等. 有了這個方法,就可以很容易的實現(xiàn)網(wǎng)頁中的文本編輯器.
    如果靈活運用,可以很好的輔助我們完成各種項目.
    使用的例子如下:
    1、〖全選〗命令的實現(xiàn)
    [格式]:document.execCommand("selectAll")
    [說明]將選種網(wǎng)頁中的全部內(nèi)容!
    [舉例]在<body></body>之間加入:<a href="#" οnclick=document.execCommand("selectAll")>全選</a>
    2、〖打開〗命令的實現(xiàn)
    [格式]:document.execCommand("open")
    [說明]這跟VB等編程設(shè)計中的web browser控件中的命令有些相似,大家也可依此琢磨琢磨。
    [舉例]在<body></body>之間加入:<a href="#" οnclick=document.execCommand("open")>打開</a>
    3、〖另存為〗命令的實現(xiàn)
    [格式]:document.execCommand("saveAs")
    [說明]將該網(wǎng)頁保存到本地盤的其它目錄!
    [舉例]在<body></body>之間加入:<a href="#" οnclick=document.execCommand("saveAs")>另存為</a>
    4、〖打印〗命令的實現(xiàn)
    [格式]:document.execCommand("print")
    [說明]當然,你必須裝了打印機!
    [舉例]在<body></body>之間加入:<a href="#" οnclick=document.execCommand("print")>打印</a>
    Js代碼? 下面列出的是指令參數(shù)及意義
    //相當于單擊文件中的打開按鈕
    document.execCommand("Open");
    //將當前頁面 另存為
    document.execCommand("SaveAs");
    //剪貼選中的文字到剪貼板;
    document.execCommand("Cut","false",null);
    //刪除選中的文字;
    document.execCommand("Delete","false",null);
    //改變選中區(qū)域的字體;
    document.execCommand("FontName","false",sFontName);
    //改變選中區(qū)域的字體大小;
    document.execCommand("FontSize","false",sSize|iSize);
    //設(shè)置前景顏色;
    document.execCommand("ForeColor","false",sColor);
    //使絕對定位的對象可直接拖動;
    document.execCommand("2D-Position","false","true");
    //使對象定位變成絕對定位;
    document.execCommand("AbsolutePosition","false","true");
    //設(shè)置背景顏色;
    document.execCommand("BackColor","false",sColor);
    //使選中區(qū)域的文字加粗;
    document.execCommand("Bold","false",null);
    //復(fù)制選中的文字到剪貼板;
    document.execCommand("Copy","false",null);
    //設(shè)置指定錨點為書簽;
    document.execCommand("CreateBookmark","false",sAnchorName);
    //將選中文 本變成超連接,若第二個參數(shù)為true,會出現(xiàn)參數(shù)設(shè)置對話框;
    document.execCommand("CreateLink","false",sLinkURL);
    //設(shè)置當前塊的標簽名;
    document.execCommand("FormatBlock","false",sTagName); ?
    //相當于單擊文件中的打開按鈕
    document.execCommand("Open");
    //將當前頁面另存為
    document.execCommand("SaveAs");
    //剪貼選中的文字到剪貼板;
    document.execCommand("Cut","false",null);
    //刪除選中的文字;
    document.execCommand("Delete","false",null);
    //改變選中區(qū)域的字體;
    document.execCommand("FontName","false",sFontName);
    //改變選中區(qū)域的字體大小;
    document.execCommand("FontSize","false",sSize|iSize);
    //設(shè)置前景顏色;
    document.execCommand("ForeColor","false",sColor);
    //使絕對定位的對象可直接拖動;
    document.execCommand("2D-Position","false","true");
    //使對象定位變成絕對定位;
    document.execCommand("AbsolutePosition","false","true");
    //設(shè)置背景顏色;
    document.execCommand("BackColor","false",sColor);
    //使選中區(qū)域的文字加粗;
    document.execCommand("Bold","false",null);
    //復(fù)制選中的文字到剪貼板;
    document.execCommand("Copy","false",null);
    //設(shè)置指定錨點為書簽;
    document.execCommand("CreateBookmark","false",sAnchorName);
    //將選中文本變成超連接,若第二個參數(shù)為true,會出現(xiàn)參數(shù)設(shè)置對話框;
    document.execCommand("CreateLink","false",sLinkURL);
    //設(shè)置當前塊的標簽名;
    document.execCommand("FormatBlock","false",sTagName);
    document對象execCommand通常在IE中在線處理Html數(shù)據(jù)時非常有用,它可以讓你輕而易舉實現(xiàn)文字的加粗、加顏色、加字體等一系列的命令。
    ??? D-Position 允許通過拖曳移動絕對定位的對象。
    ??? AbsolutePosition 設(shè)定元素的 position 屬性為“absolute”(絕對)。
    ??? BackColor 設(shè)置或獲取當前選中區(qū)的背景顏色。
    ??? BlockDirLTR 目前尚未支持。
    ??? BlockDirRTL 目前尚未支持。
    ??? Bold 切換當前選中區(qū)的粗體顯示與否。
    ??? BrowseMode 目前尚未支持。
    ??? Copy 將當前選中區(qū)復(fù)制到剪貼板。
    ??? CreateBookmark 創(chuàng)建一個書簽錨或獲取當前選中區(qū)或插入點的書簽錨的名稱。
    ??? CreateLink 在當前選中區(qū)上插入超級鏈接,或顯示一個對話框允許用戶指定要為當前選中區(qū)插入的超級鏈接的 URL。
    ??? Cut 將當前選中區(qū)復(fù)制到剪貼板并刪除之。
    ??? Delete 刪除當前選中區(qū)。
    ??? DirLTR 目前尚未支持。
    ??? DirRTL 目前尚未支持。
    ??? EditMode 目前尚未支持。
    ??? FontName 設(shè)置或獲取當前選中區(qū)的字體。
    ??? FontSize 設(shè)置或獲取當前選中區(qū)的字體大小。
    ??? ForeColor 設(shè)置或獲取當前選中區(qū)的前景(文本)顏色。
    ??? FormatBlock 設(shè)置當前塊格式化標簽。
    ??? Indent 增加選中文本的縮進。
    ??? InlineDirLTR 目前尚未支持。
    ??? InlineDirRTL 目前尚未支持。
    ??? InsertButton 用按鈕控件覆蓋當前選中區(qū)。
    ??? InsertFieldset 用方框覆蓋當前選中區(qū)。
    ??? InsertHorizontalRule 用水平線覆蓋當前選中區(qū)。
    ??? InsertIFrame 用內(nèi)嵌框架覆蓋當前選中區(qū)。
    ??? InsertImage 用圖像覆蓋當前選中區(qū)。
    ??? InsertInputButton 用按鈕控件覆蓋當前選中區(qū)。
    ??? InsertInputCheckbox 用復(fù)選框控件覆蓋當前選中區(qū)。
    ??? InsertInputFileUpload 用文件上載控件覆蓋當前選中區(qū)。
    ??? InsertInputHidden 插入隱藏控件覆蓋當前選中區(qū)。
    ??? InsertInputImage 用圖像控件覆蓋當前選中區(qū)。
    ??? InsertInputPassword 用密碼控件覆蓋當前選中區(qū)。
    ??? InsertInputRadio 用單選鈕控件覆蓋當前選中區(qū)。
    ??? InsertInputReset 用重置控件覆蓋當前選中區(qū)。
    ??? InsertInputSubmit 用提交控件覆蓋當前選中區(qū)。
    ??? InsertInputText 用文本控件覆蓋當前選中區(qū)。
    ??? InsertMarquee 用空字幕覆蓋當前選中區(qū)。
    ?? InsertOrderedList 切換當前選中區(qū)是編號列表還是常規(guī)格式化塊。
    ??? InsertParagraph 用換行覆蓋當前選中區(qū)。
    ??? InsertSelectDropdown 用下拉框控件覆蓋當前選中區(qū)。
    ??? InsertSelectListbox 用列表框控件覆蓋當前選中區(qū)。
    ??? InsertTextArea 用多行文本輸入控件覆蓋當前選中區(qū)。
    ??? InsertUnorderedList 切換當前選中區(qū)是項目符號列表還是常規(guī)格式化塊。
    ??? Italic 切換當前選中區(qū)斜體顯示與否。
    ??? JustifyCenter 將當前選中區(qū)在所在格式化塊置中。
    ??? JustifyFull 目前尚未支持。
    ??? JustifyLeft 將當前選中區(qū)所在格式化塊左對齊。
    ??? JustifyNone 目前尚未支持。
    ??? JustifyRight 將當前選中區(qū)所在格式化塊右對齊。
    ??? LiveResize 迫使 MSHTML 編輯器在縮放或移動過程中持續(xù)更新元素外觀,而不是只在移動或縮放完成后更新。
    ??? MultipleSelection 允許當用戶按住 Shift 或 Ctrl 鍵時一次選中多于一個站點可選元素。
    ??? Open 目前尚未支持。
    ??? Outdent 減少選中區(qū)所在格式化塊的縮進。
    ??? OverWrite 切換文本狀態(tài)的插入和覆蓋。
    ??? Paste 用剪貼板內(nèi)容覆蓋當前選中區(qū)。
    ??? PlayImage 目前尚未支持。
    ??? Print 打開打印對話框以便用戶可以打印當前頁。
    ??? Redo 目前尚未支持。
    ??? Refresh 刷新當前文檔。
    ??? RemoveFormat 從當前選中區(qū)中刪除格式化標簽。
    ??? RemoveParaFormat 目前尚未支持。
    ??? SaveAs 將當前 Web 頁面保存為文件。
    ??? SelectAll 選中整個文檔。
    ??? SizeToControl 目前尚未支持。
    ??? SizeToControlHeight 目前尚未支持。
    ??? SizeToControlWidth 目前尚未支持。
    ??? Stop 目前尚未支持。
    ??? StopImage 目前尚未支持。
    ??? StrikeThrough 目前尚未支持。
    ??? Subscript 目前尚未支持。
    ??? Superscript 目前尚未支持。
    ??? UnBookmark 從當前選中區(qū)中刪除全部書簽。
    ??? Underline 切換當前選中區(qū)的下劃線顯示與否。
    ??? Undo 目前尚未支持。
    ??? Unlink 從當前選中區(qū)中刪除全部超級鏈接。
    ??? Unselect 清除當前選中區(qū)的選中狀態(tài)。
  • document.execCommand()方法處理Html數(shù)據(jù)時常用語法格式 如下: 復(fù)制內(nèi)容到剪貼板 代碼 : document.execCommand(sCommand[,交互方式, 動態(tài)參數(shù) ]) 其中:sCommand為指令參數(shù)(如下例中的"2D-Position"),交互方式參數(shù)如果是true的話將顯示對話框,如果為false的話,則不顯示對話框(下例中的"false"即表示不顯示對話框),動態(tài)參數(shù)一般為一可用值或?qū)傩?值(如下例中的"true")。 document.execCommand("2D-Position","false","true"); 調(diào)用execCommand()可以實現(xiàn)瀏覽器菜單 的很多功能. 如保存文件 ,打開新文件,撤消、重做操作...等等. 有了這個方法,就可以很容易的實現(xiàn)網(wǎng)頁中的文本編輯器. 如果靈活運用,可以很好的輔助我們完成各種項目. 使用的例子如下: 1、〖全選〗命令的實現(xiàn) [格式]:document.execCommand("selectAll") [說明]將選種網(wǎng)頁中的全部內(nèi)容! [舉例]在<body></body>之間加入: <a href="#" onclick=document.execCommand("selectAll")>全選</a> 2、〖打開〗命令的實現(xiàn) [格式]:document.execCommand("open") [說明]這跟VB等編程設(shè)計中的web browser控件中的命令有些相似,大家也可依此琢磨琢磨。 [舉例]在<body></body>之間加入: <a href="#" onclick=document.execCommand("open")>打開</a>3、〖另存為〗命令的實現(xiàn) [格式]:document.execCommand("saveAs") [說明]將該網(wǎng)頁保存到本地盤的其它目錄! [舉例]在<body></body>之間加入: <a href="#" onclick=document.execCommand("saveAs")>另存為</a>4、〖打印〗命令的實現(xiàn) [格式]:document.execCommand("print") [說明]當然,你必須裝了打印機! [舉例]在<body></body>之間加入: <a href="#" onclick=document.execCommand("print")>打印</a>Js代碼 下面列出的是指令參數(shù)及意義//相當于單擊文件中的打開按鈕 document.execCommand("Open"); //將當前頁面 另存為 document.execCommand("SaveAs"); //剪貼選中的文字到剪貼板; document.execCommand("Cut","false",null); //刪除選中的文字; document.execCommand("Delete","false",null); //改變選中區(qū)域的字體; document.execCommand("FontName","false",sFontName); //改變選中區(qū)域的字體大小; document.execCommand("FontSize","false",sSize|iSize); //設(shè)置前景顏色; document.execCommand("ForeColor","false",sColor); //使絕對定位的對象可直接拖動; document.execCommand("2D-Position","false","true"); //使對象定位變成絕對定位; document.execCommand("AbsolutePosition","false","true"); //設(shè)置背景顏色; document.execCommand("BackColor","false",sColor); //使選中區(qū)域的文字加粗; document.execCommand("Bold","false",null); //復(fù)制選中的文字到剪貼板; document.execCommand("Copy","false",null); //設(shè)置指定錨點為書簽; document.execCommand("CreateBookmark","false",sAnchorName); //將選中文 本變成超連接,若第二個參數(shù)為true,會出現(xiàn)參數(shù)設(shè)置對話框; document.execCommand("CreateLink","false",sLinkURL); //設(shè)置當前塊的標簽名; document.execCommand("FormatBlock","false",sTagName); //相當于單擊文件中的打開按鈕 document.execCommand("Open");//將當前頁面另存為 document.execCommand("SaveAs");//剪貼選中的文字到剪貼板; document.execCommand("Cut","false",null);//刪除選中的文字; document.execCommand("Delete","false",null); //改變選中區(qū)域的字體; document.execCommand("FontName","false",sFontName); //改變選中區(qū)域的字體大小; document.execCommand("FontSize","false",sSize|iSize); //設(shè)置前景顏色; document.execCommand("ForeColor","false",sColor);//使絕對定位的對象可直接拖動; document.execCommand("2D-Position","false","true");//使對象定位變成絕對定位; document.execCommand("AbsolutePosition","false","true");//設(shè)置背景顏色; document.execCommand("BackColor","false",sColor);//使選中區(qū)域的文字加粗; document.execCommand("Bold","false",null);//復(fù)制選中的文字到剪貼板; document.execCommand("Copy","false",null);//設(shè)置指定錨點為書簽; document.execCommand("CreateBookmark","false",sAnchorName);//將選中文本變成超連接,若第二個參數(shù)為true,會出現(xiàn)參數(shù)設(shè)置對話框; document.execCommand("CreateLink","false",sLinkURL);//設(shè)置當前塊的標簽名; document.execCommand("FormatBlock","false",sTagName); document對象execCommand通常在IE中在線處理Html數(shù)據(jù)時非常有用,它可以讓你輕而易舉實現(xiàn)文字的加粗、加顏色、加字體等一系列的命令。D-Position 允許通過拖曳移動絕對定位的對象。 AbsolutePosition 設(shè)定元素的 position 屬性為“absolute”(絕對)。 BackColor 設(shè)置或獲取當前選中區(qū)的背景顏色。 BlockDirLTR 目前尚未支持。 BlockDirRTL 目前尚未支持。 Bold 切換當前選中區(qū)的粗體顯示與否。 BrowseMode 目前尚未支持。 Copy 將當前選中區(qū)復(fù)制到剪貼板。 CreateBookmark 創(chuàng)建一個書簽錨或獲取當前選中區(qū)或插入點的書簽錨的名稱。 CreateLink 在當前選中區(qū)上插入超級鏈接,或顯示一個對話框允許用戶指定要為當前選中區(qū)插入的超級鏈接的 URL。 Cut 將當前選中區(qū)復(fù)制到剪貼板并刪除之。 Delete 刪除當前選中區(qū)。 DirLTR 目前尚未支持。 DirRTL 目前尚未支持。 EditMode 目前尚未支持。 FontName 設(shè)置或獲取當前選中區(qū)的字體。 FontSize 設(shè)置或獲取當前選中區(qū)的字體大小。 ForeColor 設(shè)置或獲取當前選中區(qū)的前景(文本)顏色。 FormatBlock 設(shè)置當前塊格式化標簽。 Indent 增加選中文本的縮進。 InlineDirLTR 目前尚未支持。 InlineDirRTL 目前尚未支持。 InsertButton 用按鈕控件覆蓋當前選中區(qū)。 InsertFieldset 用方框覆蓋當前選中區(qū)。 InsertHorizontalRule 用水平線覆蓋當前選中區(qū)。 InsertIFrame 用內(nèi)嵌框架覆蓋當前選中區(qū)。 InsertImage 用圖像覆蓋當前選中區(qū)。 InsertInputButton 用按鈕控件覆蓋當前選中區(qū)。 InsertInputCheckbox 用復(fù)選框控件覆蓋當前選中區(qū)。 InsertInputFileUpload 用文件上載控件覆蓋當前選中區(qū)。 InsertInputHidden 插入隱藏控件覆蓋當前選中區(qū)。 InsertInputImage 用圖像控件覆蓋當前選中區(qū)。 InsertInputPassword 用密碼控件覆蓋當前選中區(qū)。 InsertInputRadio 用單選鈕控件覆蓋當前選中區(qū)。 InsertInputReset 用重置控件覆蓋當前選中區(qū)。 InsertInputSubmit 用提交控件覆蓋當前選中區(qū)。 InsertInputText 用文本控件覆蓋當前選中區(qū)。 InsertMarquee 用空字幕覆蓋當前選中區(qū)。 InsertOrderedList 切換當前選中區(qū)是編號列表還是常規(guī)格式化塊。 InsertParagraph 用換行覆蓋當前選中區(qū)。 InsertSelectDropdown 用下拉框控件覆蓋當前選中區(qū)。 InsertSelectListbox 用列表框控件覆蓋當前選中區(qū)。 InsertTextArea 用多行文本輸入控件覆蓋當前選中區(qū)。 InsertUnorderedList 切換當前選中區(qū)是項目符號列表還是常規(guī)格式化塊。 Italic 切換當前選中區(qū)斜體顯示與否。 JustifyCenter 將當前選中區(qū)在所在格式化塊置中。 JustifyFull 目前尚未支持。 JustifyLeft 將當前選中區(qū)所在格式化塊左對齊。 JustifyNone 目前尚未支持。 JustifyRight 將當前選中區(qū)所在格式化塊右對齊。 LiveResize 迫使 MSHTML 編輯器在縮放或移動過程中持續(xù)更新元素外觀,而不是只在移動或縮放完成后更新。 MultipleSelection 允許當用戶按住 Shift 或 Ctrl 鍵時一次選中多于一個站點可選元素。 Open 目前尚未支持。 Outdent 減少選中區(qū)所在格式化塊的縮進。 OverWrite 切換文本狀態(tài)的插入和覆蓋。 Paste 用剪貼板內(nèi)容覆蓋當前選中區(qū)。 PlayImage 目前尚未支持。 Print 打開打印對話框以便用戶可以打印當前頁。 Redo 目前尚未支持。 Refresh 刷新當前文檔。 RemoveFormat 從當前選中區(qū)中刪除格式化標簽。 RemoveParaFormat 目前尚未支持。 SaveAs 將當前 Web 頁面保存為文件。 SelectAll 選中整個文檔。 SizeToControl 目前尚未支持。 SizeToControlHeight 目前尚未支持。 SizeToControlWidth 目前尚未支持。 Stop 目前尚未支持。 StopImage 目前尚未支持。 StrikeThrough 目前尚未支持。 Subscript 目前尚未支持。 Superscript 目前尚未支持。 UnBookmark 從當前選中區(qū)中刪除全部書簽。 Underline 切換當前選中區(qū)的下劃線顯示與否。 Undo 目前尚未支持。 Unlink 從當前選中區(qū)中刪除全部超級鏈接。 Unselect 清除當前選中區(qū)的選中狀態(tài)。關(guān)于document.execCommand: 要執(zhí)行編輯命令,可調(diào)用 document.execCommand,并傳遞對應(yīng)于命令 ID 的字符串。另外還有可選的第二個參數(shù) ,該參數(shù)指定如果可以應(yīng)用的話是否顯示此命令的用戶界面。傳遞整數(shù) 1 將顯示用戶界面,整數(shù) 0 將跳過它。這個參數(shù)通常不用于編輯命令。因為默認值為 0,所以假如您沒有使用第三個參數(shù)(在這種情況下,還必須為第二個參數(shù)傳遞值),一般可以不管它。第三個參數(shù)也是可選的, 在可應(yīng)用的情況下,使用它來將任何所需參數(shù)傳遞給該命令。
  • document.execCommand()方法處理Html數(shù)據(jù)時常用語法格式 如下:
  • 復(fù)制內(nèi)容到剪貼板
  • 代碼 :
  • document.execCommand(sCommand[,交互方式, 動態(tài)參數(shù) ])
  • 其中:sCommand為指令參數(shù)(如下例中的"2D-Position"),交互方式參數(shù)如果是true的話將顯示對話框,如果為false的話,則不顯示對話框(下例中的"false"即表示不顯示對話框),動態(tài)參數(shù)一般為一可用值或?qū)傩?值(如下例中的"true")。
  • document.execCommand("2D-Position","false","true");
  • 調(diào)用execCommand()可以實現(xiàn)瀏覽器菜單 的很多功能. 如保存文件 ,打開新文件,撤消、重做操作...等等. 有了這個方法,就可以很容易的實現(xiàn)網(wǎng)頁中的文本編輯器.
  • 如果靈活運用,可以很好的輔助我們完成各種項目.
  • 使用的例子如下:
  • 1、〖全選〗命令的實現(xiàn)
  • [格式]:document.execCommand("selectAll")
  • [說明]將選種網(wǎng)頁中的全部內(nèi)容!
  • [舉例]在<body></body>之間加入:
  • <a href="#" οnclick=document.execCommand("selectAll")>全選</a>
  • 2、〖打開〗命令的實現(xiàn)
  • [格式]:document.execCommand("open")
  • [說明]這跟VB等編程設(shè)計中的web browser控件中的命令有些相似,大家也可依此琢磨琢磨。
  • [舉例]在<body></body>之間加入:
  • <a href="#" οnclick=document.execCommand("open")>打開</a>
  • 3、〖另存為〗命令的實現(xiàn)
  • [格式]:document.execCommand("saveAs")
  • [說明]將該網(wǎng)頁保存到本地盤的其它目錄!
  • [舉例]在<body></body>之間加入:
  • <a href="#" οnclick=document.execCommand("saveAs")>另存為</a>
  • 4、〖打印〗命令的實現(xiàn)
  • [格式]:document.execCommand("print")
  • [說明]當然,你必須裝了打印機!
  • [舉例]在<body></body>之間加入:
  • <a href="#" οnclick=document.execCommand("print")>打印</a>
  • Js代碼 下面列出的是指令參數(shù)及意義
  • //相當于單擊文件中的打開按鈕
  • document.execCommand("Open");
  • //將當前頁面 另存為
  • document.execCommand("SaveAs");
  • //剪貼選中的文字到剪貼板;
  • document.execCommand("Cut","false",null);
  • //刪除選中的文字;
  • document.execCommand("Delete","false",null);
  • //改變選中區(qū)域的字體;
  • document.execCommand("FontName","false",sFontName);
  • //改變選中區(qū)域的字體大小;
  • document.execCommand("FontSize","false",sSize|iSize);
  • //設(shè)置前景顏色;
  • document.execCommand("ForeColor","false",sColor);
  • //使絕對定位的對象可直接拖動;
  • document.execCommand("2D-Position","false","true");
  • //使對象定位變成絕對定位;
  • document.execCommand("AbsolutePosition","false","true");
  • //設(shè)置背景顏色;
  • document.execCommand("BackColor","false",sColor);
  • //使選中區(qū)域的文字加粗;
  • document.execCommand("Bold","false",null);
  • //復(fù)制選中的文字到剪貼板;
  • document.execCommand("Copy","false",null);
  • //設(shè)置指定錨點為書簽;
  • document.execCommand("CreateBookmark","false",sAnchorName);
  • //將選中文 本變成超連接,若第二個參數(shù)為true,會出現(xiàn)參數(shù)設(shè)置對話框;
  • document.execCommand("CreateLink","false",sLinkURL);
  • //設(shè)置當前塊的標簽名;
  • document.execCommand("FormatBlock","false",sTagName);
  • //相當于單擊文件中的打開按鈕
  • document.execCommand("Open");
  • //將當前頁面另存為
  • document.execCommand("SaveAs");
  • //剪貼選中的文字到剪貼板;
  • document.execCommand("Cut","false",null);
  • //刪除選中的文字;
  • document.execCommand("Delete","false",null);
  • //改變選中區(qū)域的字體;
  • document.execCommand("FontName","false",sFontName);
  • //改變選中區(qū)域的字體大小;
  • document.execCommand("FontSize","false",sSize|iSize);
  • //設(shè)置前景顏色;
  • document.execCommand("ForeColor","false",sColor);
  • //使絕對定位的對象可直接拖動;
  • document.execCommand("2D-Position","false","true");
  • //使對象定位變成絕對定位;
  • document.execCommand("AbsolutePosition","false","true");
  • //設(shè)置背景顏色;
  • document.execCommand("BackColor","false",sColor);
  • //使選中區(qū)域的文字加粗;
  • document.execCommand("Bold","false",null);
  • //復(fù)制選中的文字到剪貼板;
  • document.execCommand("Copy","false",null);
  • //設(shè)置指定錨點為書簽;
  • document.execCommand("CreateBookmark","false",sAnchorName);
  • //將選中文本變成超連接,若第二個參數(shù)為true,會出現(xiàn)參數(shù)設(shè)置對話框;
  • document.execCommand("CreateLink","false",sLinkURL);
  • //設(shè)置當前塊的標簽名;
  • document.execCommand("FormatBlock","false",sTagName);
  • document對象execCommand通常在IE中在線處理Html數(shù)據(jù)時非常有用,它可以讓你輕而易舉實現(xiàn)文字的加粗、加顏色、加字體等一系列的命令。
  • D-Position 允許通過拖曳移動絕對定位的對象。
  • AbsolutePosition 設(shè)定元素的 position 屬性為“absolute”(絕對)。
  • BackColor 設(shè)置或獲取當前選中區(qū)的背景顏色。
  • BlockDirLTR 目前尚未支持。
  • BlockDirRTL 目前尚未支持。
  • Bold 切換當前選中區(qū)的粗體顯示與否。
  • BrowseMode 目前尚未支持。
  • Copy 將當前選中區(qū)復(fù)制到剪貼板。
  • CreateBookmark 創(chuàng)建一個書簽錨或獲取當前選中區(qū)或插入點的書簽錨的名稱。
  • CreateLink 在當前選中區(qū)上插入超級鏈接,或顯示一個對話框允許用戶指定要為當前選中區(qū)插入的超級鏈接的 URL。
  • Cut 將當前選中區(qū)復(fù)制到剪貼板并刪除之。
  • Delete 刪除當前選中區(qū)。
  • DirLTR 目前尚未支持。
  • DirRTL 目前尚未支持。
  • EditMode 目前尚未支持。
  • FontName 設(shè)置或獲取當前選中區(qū)的字體。
  • FontSize 設(shè)置或獲取當前選中區(qū)的字體大小。
  • ForeColor 設(shè)置或獲取當前選中區(qū)的前景(文本)顏色。
  • FormatBlock 設(shè)置當前塊格式化標簽。
  • Indent 增加選中文本的縮進。
  • InlineDirLTR 目前尚未支持。
  • InlineDirRTL 目前尚未支持。
  • InsertButton 用按鈕控件覆蓋當前選中區(qū)。
  • InsertFieldset 用方框覆蓋當前選中區(qū)。
  • InsertHorizontalRule 用水平線覆蓋當前選中區(qū)。
  • InsertIFrame 用內(nèi)嵌框架覆蓋當前選中區(qū)。
  • InsertImage 用圖像覆蓋當前選中區(qū)。
  • InsertInputButton 用按鈕控件覆蓋當前選中區(qū)。
  • InsertInputCheckbox 用復(fù)選框控件覆蓋當前選中區(qū)。
  • InsertInputFileUpload 用文件上載控件覆蓋當前選中區(qū)。
  • InsertInputHidden 插入隱藏控件覆蓋當前選中區(qū)。
  • InsertInputImage 用圖像控件覆蓋當前選中區(qū)。
  • InsertInputPassword 用密碼控件覆蓋當前選中區(qū)。
  • InsertInputRadio 用單選鈕控件覆蓋當前選中區(qū)。
  • InsertInputReset 用重置控件覆蓋當前選中區(qū)。
  • InsertInputSubmit 用提交控件覆蓋當前選中區(qū)。
  • InsertInputText 用文本控件覆蓋當前選中區(qū)。
  • InsertMarquee 用空字幕覆蓋當前選中區(qū)。
  • InsertOrderedList 切換當前選中區(qū)是編號列表還是常規(guī)格式化塊。
  • InsertParagraph 用換行覆蓋當前選中區(qū)。
  • InsertSelectDropdown 用下拉框控件覆蓋當前選中區(qū)。
  • InsertSelectListbox 用列表框控件覆蓋當前選中區(qū)。
  • InsertTextArea 用多行文本輸入控件覆蓋當前選中區(qū)。
  • InsertUnorderedList 切換當前選中區(qū)是項目符號列表還是常規(guī)格式化塊。
  • Italic 切換當前選中區(qū)斜體顯示與否。
  • JustifyCenter 將當前選中區(qū)在所在格式化塊置中。
  • JustifyFull 目前尚未支持。
  • JustifyLeft 將當前選中區(qū)所在格式化塊左對齊。
  • JustifyNone 目前尚未支持。
  • JustifyRight 將當前選中區(qū)所在格式化塊右對齊。
  • LiveResize 迫使 MSHTML 編輯器在縮放或移動過程中持續(xù)更新元素外觀,而不是只在移動或縮放完成后更新。
  • MultipleSelection 允許當用戶按住 Shift 或 Ctrl 鍵時一次選中多于一個站點可選元素。
  • Open 目前尚未支持。
  • Outdent 減少選中區(qū)所在格式化塊的縮進。
  • OverWrite 切換文本狀態(tài)的插入和覆蓋。
  • Paste 用剪貼板內(nèi)容覆蓋當前選中區(qū)。
  • PlayImage 目前尚未支持。
  • Print 打開打印對話框以便用戶可以打印當前頁。
  • Redo 目前尚未支持。
  • Refresh 刷新當前文檔。
  • RemoveFormat 從當前選中區(qū)中刪除格式化標簽。
  • RemoveParaFormat 目前尚未支持。
  • SaveAs 將當前 Web 頁面保存為文件。
  • SelectAll 選中整個文檔。
  • SizeToControl 目前尚未支持。
  • SizeToControlHeight 目前尚未支持。
  • SizeToControlWidth 目前尚未支持。
  • Stop 目前尚未支持。
  • StopImage 目前尚未支持。
  • StrikeThrough 目前尚未支持。
  • Subscript 目前尚未支持。
  • Superscript 目前尚未支持。
  • UnBookmark 從當前選中區(qū)中刪除全部書簽。
  • Underline 切換當前選中區(qū)的下劃線顯示與否。
  • Undo 目前尚未支持。
  • Unlink 從當前選中區(qū)中刪除全部超級鏈接。
  • Unselect 清除當前選中區(qū)的選中狀態(tài)。
  • 關(guān)于document.execCommand:
  • 要執(zhí)行編輯命令,可調(diào)用 document.execCommand,并傳遞對應(yīng)于命令I(lǐng)D的字符串。
  • 另外還有可選的第二個參數(shù) ,該參數(shù)指定如果可以應(yīng)用的話是否顯示此命令的用戶界面。
  • 傳遞整數(shù)1將顯示用戶界面,整數(shù)0將跳過它。這個參數(shù)通常不用于編輯命令。
  • 因為默認值為0,所以假如您沒有使用第三個參數(shù)(在這種情況下,還必須為第二個參數(shù)傳遞值),
  • 一般可以不管它。第三個參數(shù)也是可選的, 在可應(yīng)用的情況下,使用它來將任何所需參數(shù)傳遞給該命令。
  • 注意:

  • body{
  • /* font-weight: 500;
  • font-size: 1.05em;
  • font-family: "Microsoft YaHei","宋體","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo;*/
  • }
  • 將會導(dǎo)致字體加粗時沒有作用。沒有理清楚是為什么?,你知道請告訴我。
  • 這是拼湊的模板:

    <!DOCTYPE html> <html lang="zh"> <head> <!--<meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> --><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>純CSS3制作可編輯的微軟Word樣式文檔|DEMO_jQuery之家-自由分享jQuery、html5、css3的插件庫</title><!--<link rel="stylesheet" type="text/css" href="css/sheets-of-paper-a4.css">--><!--[if IE]><script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script><![endif]--><style type="text/css">article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block;} audio,canvas,video{display:inline-block;} audio:not([controls]){display:none;height:0;}[hidden]{display:none;} html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;} body{margin:0;}a:focus{outline:thin dotted;} a:active,a:hover{outline:0;} h1{font-size:2em;margin:0.67em 0;} abbr[title]{border-bottom:1px dotted;} b,strong{font-weight:bold;}dfn{font-style:italic;} hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0;} mark{background:#ff0;color:#000;} code,kbd,pre,samp{font-family:monospace,serif;font-size:1em;} pre{white-space:pre-wrap;}q{quotes:"\201C" "\201D" "\2018" "\2019";} small{font-size:80%;} sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline;} sup{top:-0.5em;}sub{bottom:-0.25em;} img{border:0;}svg:not(:root){overflow:hidden;} figure{margin:0;}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em;} legend{border:0;padding:0;} button,input,select,textarea{font-family:inherit;font-size:100%;margin:0;} button,input{line-height:normal;}button,select{text-transform:none;} button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;} button[disabled],html input[disabled]{cursor:default;} input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0;} input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;} input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none;} button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0;} textarea{overflow:auto;vertical-align:top;}table{border-collapse:collapse;border-spacing:0;}</style><style type="text/css"> [class^="icon-"], [class*=" icon-"] {font-family: 'Microsoft Yahei';speak: none;font-style: normal;font-weight: normal;font-variant: normal;text-transform: none;line-height: 1;/* Better Font Rendering =========== */-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale; }body, html { font-size: 100%; padding: 0; margin: 0;}/* Reset */ *, *:after, *:before {-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box; }/* Clearfix hack by Nicolas Gallagher: http://nicolasgallagher.com/micro-clearfix-hack/ */ .clearfix:before, .clearfix:after {content: " ";display: table; }.clearfix:after {clear: both; }body{ /* font-weight: 500;font-size: 1.05em;font-family: "Microsoft YaHei","宋體","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo;*/ } a{ color: rgba(255, 255, 255, 0.6);outline: none;text-decoration: none;-webkit-transition: 0.2s;transition: 0.2s;} a:hover,a:focus{color:#74777b;text-decoration: none;} .htmleaf-container{margin: 0 auto; }.bgcolor-1 { background: #f0efee; } .bgcolor-2 { background: #f9f9f9; } .bgcolor-3 { background: #e8e8e8; }/*light grey*/ .bgcolor-4 { background: #2f3238; color: #fff; }/*Dark grey*/ .bgcolor-5 { background: #df6659; color: #521e18; }/*pink1*/ .bgcolor-6 { background: #2fa8ec; }/*sky blue*/ .bgcolor-7 { background: #d0d6d6; }/*White tea*/ .bgcolor-8 { background: #3d4444; color: #fff; }/*Dark grey2*/ .bgcolor-9 { background: #ef3f52; color: #fff;}/*pink2*/ .bgcolor-10{ background: #64448f; color: #fff;}/*Violet*/ .bgcolor-11{ background: #3755ad; color: #fff;}/*dark blue*/ .bgcolor-12{ background: #3498DB; color: #fff;}/*light blue*/ .bgcolor-20{ background: #494A5F;color: #D5D6E2;} /* Header */ .htmleaf-header{padding: 1em 190px 1em;letter-spacing: -1px;text-align: center;background: #66677c; } .htmleaf-header h1 {color: #D5D6E2;font-weight: 600;font-size: 2em;line-height: 1;margin-bottom: 0;font-family: "Microsoft YaHei","宋體","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo; } .htmleaf-header h1 span {font-family: "Microsoft YaHei","宋體","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo;display: block;font-size: 60%;font-weight: 400;padding: 0.8em 0 0.5em 0;color: #c3c8cd; } /*nav*/ .htmleaf-demo a{color: #fff;text-decoration: none;} .htmleaf-demo{width: 100%;padding-bottom: 1.2em;} .htmleaf-demo a{display: inline-block;margin: 0.5em;padding: 0.6em 1em;border: 3px solid #fff;font-weight: 700;} .htmleaf-demo a:hover{opacity: 0.6;} .htmleaf-demo a.current{background:#1d7db1;color: #fff; } /* Top Navigation Style */ .htmleaf-links {position: relative;display: inline-block;white-space: nowrap;font-size: 1.5em;text-align: center; }.htmleaf-links::after {position: absolute;top: 0;left: 50%;margin-left: -1px;width: 2px;height: 100%;background: #dbdbdb;content: '';-webkit-transform: rotate3d(0,0,1,22.5deg);transform: rotate3d(0,0,1,22.5deg); }.htmleaf-icon {display: inline-block;margin: 0.5em;padding: 0em 0;width: 1.5em;text-decoration: none; }.htmleaf-icon span {display: none; }.htmleaf-icon:before {margin: 0 5px;text-transform: none;font-weight: normal;font-style: normal;font-variant: normal;font-family: 'Microsoft Yahei';line-height: 1;speak: none;-webkit-font-smoothing: antialiased; } /* footer */ .htmleaf-footer{width: 100%;padding-top: 10px;} .htmleaf-small{font-size: 0.8em;} .center{text-align: center;} /****/ .related {color: #fff;background: #494A5F;text-align: center;font-size: 1.25em;padding: 0.5em 0;overflow: hidden; }.related > a {vertical-align: top;width: calc(100% - 20px);max-width: 340px;display: inline-block;text-align: center;margin: 20px 10px;padding: 25px;font-family: "Microsoft YaHei","宋體","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo; } .related a {display: inline-block;text-align: left;margin: 20px auto;padding: 10px 20px;opacity: 0.8;-webkit-transition: opacity 0.3s;transition: opacity 0.3s;-webkit-backface-visibility: hidden; }.related a:hover, .related a:active {opacity: 1; }.related a img {max-width: 100%;opacity: 0.8;border-radius: 4px; } .related a:hover img, .related a:active img {opacity: 1; } .related h3{font-family: "Microsoft YaHei", sans-serif;font-size: 1.2em} .related a h3 {font-size: 0.85em;font-weight: 300;margin-top: 0.15em;color: #fff; } /* icomoon */ .icon-htmleaf-home-outline:before {content: "\e5000"; }.icon-htmleaf-arrow-forward-outline:before {content: "\e5001"; }@media screen and (max-width: 1024px) {.htmleaf-header {padding: 2em 10% 2em;}.htmleaf-header h1 {font-size:1.4em;}.htmleaf-links{font-size: 1.4em} }@media screen and (max-width: 960px) {.htmleaf-header {padding: 2em 10% 2em;}.htmleaf-header h1 {font-size:1.2em;}.htmleaf-links{font-size: 1.2em}.related h3{font-size: 1em;}.related a h3 {font-size: 0.8em;} }@media screen and (max-width: 766px) {.htmleaf-header h1 {font-size:1.3em;}.htmleaf-links{font-size: 1.3em} }@media screen and (max-width: 640px) {.htmleaf-header {padding: 2em 10% 2em;}.htmleaf-header h1 {font-size:1em;}.htmleaf-links{font-size: 1em}.related h3{font-size: 0.8em;}.related a h3 {font-size: 0.6em;} }</style><style type="text/css">/*!* HTML-Sheets-of-Paper (https://github.com/delight-im/HTML-Sheets-of-Paper)* Copyright (c) delight.im (https://www.delight.im/)* Licensed under the MIT License (https://opensource.org/licenses/MIT)*/html, body {/* Reset the document's margin values */margin: 0;/* Reset the document's padding values */padding: 0;/* Use the platform's native font as the default */font-family: "Microsoft Yahei", -apple-system, "San Francisco", "Segoe UI", "Helvetica Neue", sans-serif;/* Define a reasonable base font size */font-size: 12pt;/* Styles for better appearance on screens only -- are reset to defaults in print styles later *//* Use a non-white background color to make the content areas stick out from the full page box */background-color: #eee; } /* Styles that are shared by all elements */ * {/* Include the content box as well as padding and border for precise definitions */box-sizing: border-box;-moz-box-sizing: border-box; } .page {/* Styles for better appearance on screens only -- are reset to defaults in print styles later *//* Divide single pages with some space and center all pages horizontally */margin: 1cm auto;/* Define a white paper background that sticks out from the darker overall background */background: #fff;/* Show a drop shadow beneath each page */box-shadow: 0 4px 5px rgba(75, 75, 75, 0.2);/* Override outline from user agent stylesheets */outline: 0; } /* Defines a class for manual page breaks via inserted .page-break element */ div.page-break {page-break-after: always; } /* For top-level headings only */ h1 {/* Force page breaks after */page-break-before: always; } /* For all headings */ h1, h2, h3, h4, h5, h6 {/* Avoid page breaks immediately */page-break-after: avoid; } /* For all paragraph tags */ p {/* Reset the margin so that the text starts and ends at the expected marks */margin: 0; } /* For adjacent paragraph tags */ p + p {/* Restore the spacing between the paragraphs */margin-top: 0.5cm; } /* For links in the document */ a {/* Prevent colorization or decoration */text-decoration: none;color: black; } /* For tables in the document */ table {/* Avoid page breaks inside */page-break-inside: avoid; } /* Use CSS Paged Media to switch from continuous documents to sheet-like documents with separate pages */ @page {/* You can only change the size, margins, orphans, widows and page breaks here *//* Require that at least this many lines of a paragraph must be left at the bottom of a page */orphans: 4;/* Require that at least this many lines of a paragraph must be left at the top of a new page */widows: 2; } /* When the document is actually printed */ @media print {html, body {/* Reset the document's background color */background-color: #fff;}.page {/* Reset all page styles that have been for better screen appearance only *//* Break cascading by using the !important rule *//* These resets are absolute must-haves for the print styles and the specificity may be higher elsewhere */width: initial !important;min-height: initial !important;margin: 0 !important;padding: 0 !important;border: initial !important;border-radius: initial !important;background: initial !important;box-shadow: initial !important;/* Force page breaks after each .page element of the document */page-break-after: always;} } .page {/* Styles for better appearance on screens only -- are reset to defaults in print styles later *//* Reflect the paper width in the screen rendering (must match size from @page rule) */width: 21cm;/* Reflect the paper height in the screen rendering (must match size from @page rule) */min-height: 29.7cm;/* Reflect the actual page margin/padding on paper in the screen rendering (must match margin from @page rule) */padding-left: 2cm;padding-top: 2cm;padding-right: 2cm;padding-bottom: 2cm; } /* Use CSS Paged Media to switch from continuous documents to sheet-like documents with separate pages */ @page {/* You can only change the size, margins, orphans, widows and page breaks here *//* Paper size and page orientation */size: A4 portrait;/* Margin per single side of the page */margin-left: 2cm;margin-top: 2cm;margin-right: 2cm;margin-bottom: 2cm; }</style> </head> <body class="document"><div class="htmleaf-container" ><header class="htmleaf-header" ><h1>純CSS3制作可編輯的微軟Word樣式文檔 <span>Generating MS Word Style Sheets Of Paper With Pure CSS</span></h1></header></div><div class="page" contenteditable="true" ><span ><h1>First 1 element</h1><p>注意,頁面中的文字是可以進行修改的。</p></span></div><div class="page" contenteditable="true"><h2>Second 2 element</h2></div><script type="text/javascript">// window.print();</script> </body> </html>

    2ccc上有個高人n年前寫的瀏覽器編輯器,可以參考Register_HtmlEdit

    5、詳細參考:https://www.cnblogs.com/xe2011/p/3144861.html

    總結(jié)

    以上是生活随笔為你收集整理的用Twebbrowser做可控编辑器与MSHTML的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 超碰在线98 | 香蕉大久久| 污视频在线观看免费 | 欧美大片aaa | 依人在线视频 | 国产精品无码一区二区三区在线看 | 国产精品久久久久久 | 欧美第九页 | 熟女人妻aⅴ一区二区三区60路 | 日韩三级在线观看 | 男生看的污网站 | 日韩精品免费一区二区三区竹菊 | 国产suv精品一区二区883 | 美女毛片| 久久加久久 | 久久免费国产 | 亚洲成人精品网 | 五月天综合网站 | 亚洲美女性生活视频 | 亚洲国产精品无码久久久 | 欧美性网站 | 免费在线黄色片 | 国产一区二区三区视频免费观看 | 日韩精品一区二区三区视频 | 国产av一区精品 | 国产色视频网站 | 国产又粗又猛又爽又黄的视频一 | 国产精品黑丝 | 国产福利一区二区 | 性欧美又大又长又硬 | 日本精品少妇 | 免费搞黄网站 | 国产午夜精品一区二区 | 亚洲三级视频在线观看 | 影音先锋黑人 | 国产女人18毛片18精品 | 黄色一级淫片 | 乳揉みま痴汉4在线播放 | 亚洲一区在线播放 | jizz免费视频 | 国产资源网 | 无码国产精品一区二区免费16 | 欧美又大粗又爽又黄大片视频 | 91大神久久| 男人爆操女人 | 夜夜爽爽 | 午夜国产在线观看 | 亚洲精品18 | 美景之屋电影免费高清完整韩剧 | 夜色导航| 国产成人精品无码播放 | 成人在线视频免费观看 | 国产精品欧美一区二区 | av在线免| 欧美日韩一级片在线观看 | 99久久国产宗和精品1上映 | 国产精品成人3p一区二区三区 | 欧美一区二区三区激情啪啪 | 国产精品v欧美精品v日韩精品 | 成人午夜av| 麻豆国产在线 | 中文在线a√在线8 | 日韩a在线 | 老司机在线永久免费观看 | 天堂久久久久 | 熟妇人妻精品一区二区三区视频 | 岳狂躁岳丰满少妇大叫 | 欧美jjzz| a人片| 十八禁视频网站在线观看 | 91麻豆精品91久久久久同性 | 日韩有码第一页 | 传媒av在线 | 99久久99久久精品国产片果冻 | 国产视频三区 | 精品一区二区三区四 | www在线观看免费视频 | 免费观看av的网站 | 亚洲免费福利 | 国产精品久久久久无码av色戒 | 美女综合网 | 久久精品视频网站 | ww久久| 亚洲每日在线 | 日韩影音| 日韩青青草 | 素人一区| 国产免费内射又粗又爽密桃视频 | 黄污视频在线观看 | 黑人玩弄人妻一区二区三区四 | 久久国产精品免费看 | 日韩欧美电影一区二区三区 | 免费观看视频一区二区 | 久草网在线视频 | 国产精品久热 | 黄色片免费网站 | 国产第一页av | 五月婷在线观看 | 久草福利在线观看 |