首頁 web前端 css教學 製作WEB線上編輯器-插入HTML標籤_經驗交流

製作WEB線上編輯器-插入HTML標籤_經驗交流

May 16, 2016 pm 12:08 PM

I used to think that the online editor of WEB was nothing more than the replacement of input content and the quick insertion of HTML code. However, when I did it, I found that although the principle is that, the implementation method is not as rigid as I thought. Since I rarely do UI things, I didn’t know until now that there is an execCommand method in the document that can solve the problem of inserting HTML tags. This method can insert the required HTML tags at the position of the cursor, and it should be noted that if there is a limit To insert a label within a range, you need to first let the range gain focus, for example:
a.focus();
a.document.execCommand('insertButton','','btn');
here The a object is an iframe object. The first parameter in execcommand is the command of the control that needs to be inserted. The second parameter is not known yet, and the third parameter is the ID name. A BUTTON control with ID=btn will be inserted here. If you want to add other attributes, just follow it. Just write, for example
a.document.execCommand('insertButton','','btn class=btnclass color=red');

Detailed list of the first parameter
2D- Position allows absolutely positioned objects to be moved by dragging.
AbsolutePosition sets the position attribute of the element to "absolute" (absolute).
BackColor sets or gets the background color of the currently selected area.
BlockDirLTR is not currently supported.
BlockDirRTL is not currently supported.
Bold Switches whether the currently selected area is bold or not.
BrowseMode is not currently supported.
Copy Copies the current selection to the clipboard.
CreateBookmark Creates a bookmark anchor or gets the name of the bookmark anchor of the current selection or insertion point.
CreateLink Inserts a hyperlink on the current selection, or displays a dialog box allowing the user to specify the URL of the hyperlink to be inserted for the current selection.
Cut Copies the current selection to the clipboard and deletes it.
Delete Delete the currently selected area.
DirLTR is not currently supported.
DirRTL is not currently supported.
EditMode is not currently supported.
FontName Sets or gets the font of the currently selected area.
FontSize sets or gets the font size of the currently selected area.
ForeColor sets or gets the foreground (text) color of the currently selected area.
FormatBlock Sets the current block formatting tag.
Indent increases the indent of the selected text.
InlineDirLTR is not supported yet.
InlineDirRTL is not currently supported.
InsertButton Use button control to cover the currently selected area.
InsertFieldset covers the currently selected area with a box.
InsertHorizontalRule covers the current selection with a horizontal line.
InsertIFrame covers the current selection with an inline frame.
InsertImage covers the current selection with an image.
InsertInputButton Use button control to cover the currently selected area.
InsertInputCheckbox Use the checkbox control to cover the currently selected area.
InsertInputFileUpload uses the file upload control to overwrite the currently selected area.
InsertInputHidden inserts a hidden control to cover the currently selected area.
InsertInputImage covers the current selection with an image control.
InsertInputPassword Use password control to cover the currently selected area.
InsertInputRadio uses a radio button control to cover the currently selected area.
InsertInputReset uses the reset control to overwrite the current selection.
InsertInputSubmit uses the submit control to overwrite the currently selected area.
InsertInputText covers the current selection with text control.
InsertMarquee covers the currently selected area with empty subtitles.
InsertOrderedList switches whether the currently selected area is a numbered list or a regular formatted block.
InsertParagraph overwrites the current selection with line breaks.
InsertSelectDropdown Use the drop-down box control to cover the currently selected area.
InsertSelectListbox Use the list box control to cover the currently selected area.
InsertTextArea covers the currently selected area with a multi-line text input control.
InsertUnorderedList switches whether the currently selected area is a bullet list or a regular formatted block.
Italic Switches whether the currently selected area is displayed in italics or not.
JustifyCenter Centers the currently selected area in the formatting block.
JustifyFull is not currently supported.
JustifyLeft will align the formatting block of the currently selected area to the left.
JustifyNone is not currently supported.
JustifyRight Right-justifies the formatting block where the currently selected area is located.
LiveResize forces the MSHTML editor to continuously update an element's appearance during scaling or movement, rather than only updating after the movement or scaling is complete.
MultipleSelection allows the user to select more than one site selectable element at a time while holding down the Shift or Ctrl key.
Open Open.
Outdent Reduce the indent of the formatting block where the selected area is located.
OverWrite switches the insertion and overwriting of text state. 
Paste 以剪貼簿內容覆蓋目前選取區。 
PlayImage 目前尚未支援。 
Print 開啟列印對話方塊以便使用者列印目前頁。 
Redo 重做。 
Refresh 刷新目前文件。 
RemoveFormat 從目前選取區移除格式化標籤。 
RemoveParaFormat 目前尚未支援。 
SaveAs 將目前 Web 頁面儲存為檔案。 
SelectAll 選取整份文件。 
SizeToControl 目前尚未支援。 
SizeToControlHeight 目前尚未支援。 
SizeToControlWidth 目前尚未支援。 
Stop 停止。 
StopImage 目前尚未支援。 
StrikeThrough 目前尚未支援。 
Subscript 目前尚未支援。 
Superscript 目前尚未支援。 
UnBookmark 從目前選取區中刪除全部書籤。 
Underline 切換目前選取區的底線顯示與否。 
Undo 撤銷。 
Unlink 從目前選取區中刪除全部超級連結。 
Unselect 清除目前選取區的選取狀態。

另外,在當前鼠標所點的位置插入字符可用以下方法:


zdfzadfasfdasdfadsf
<script> <BR>function showselect() { <BR>var oText = document.selection.createRange(); <BR>oText.text=111; <BR>} <BR></script>
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Java教學
1664
14
CakePHP 教程
1423
52
Laravel 教程
1317
25
PHP教程
1268
29
C# 教程
1242
24
Google字體可變字體 Google字體可變字體 Apr 09, 2025 am 10:42 AM

我看到Google字體推出了新設計(Tweet)。與上一次大型重新設計相比,這感覺更加迭代。我幾乎無法分辨出區別

如何使用HTML,CSS和JavaScript創建動畫倒計時計時器 如何使用HTML,CSS和JavaScript創建動畫倒計時計時器 Apr 11, 2025 am 11:29 AM

您是否曾經在項目上需要一個倒計時計時器?對於這樣的東西,可以自然訪問插件,但實際上更多

HTML數據屬性指南 HTML數據屬性指南 Apr 11, 2025 am 11:50 AM

您想了解的有關HTML,CSS和JavaScript中數據屬性的所有信息。

使Sass更快的概念證明 使Sass更快的概念證明 Apr 16, 2025 am 10:38 AM

在一個新項目開始時,Sass彙編發生在眼睛的眨眼中。感覺很棒,尤其是當它與browsersync配對時,它重新加載

我們如何創建一個在SVG中生成格子呢模式的靜態站點 我們如何創建一個在SVG中生成格子呢模式的靜態站點 Apr 09, 2025 am 11:29 AM

格子呢是一塊圖案布,通常與蘇格蘭有關,尤其是他們時尚的蘇格蘭語。在Tar​​tanify.com上,我們收集了5,000多個格子呢

如何在WordPress主題中構建VUE組件 如何在WordPress主題中構建VUE組件 Apr 11, 2025 am 11:03 AM

內聯式模板指令使我們能夠將豐富的VUE組件構建為對現有WordPress標記的逐步增強。

當您看上去時,CSS梯度變得更好 當您看上去時,CSS梯度變得更好 Apr 11, 2025 am 09:16 AM

我關注的一件事是Lea Verou&#039; s conic-Gradient()Polyfill的功能列表是最後一項:

靜態表單提供商的比較 靜態表單提供商的比較 Apr 16, 2025 am 11:20 AM

讓我們嘗試在這裡造成一個術語:“靜態表單提供商”。你帶上html

See all articles