PIXNET Logo登入

碎碎念

跳到主文

murmur

部落格全站分類:財經政論

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 11月 02 週五 201816:04
  • [Javascript] Element.insertAdjacentHTML()

轉自 https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML
--

The insertAdjacentHTML() method parses the specified text as HTML or XML and inserts the resulting nodes into the DOM tree at a specified position. It does not reparse the element it is being used on, and thus it does not corrupt the existing elements inside that element. This avoids the extra step of serialization, making it much faster than direct innerHTMLmanipulation.


SyntaxSection


element.insertAdjacentHTML(position, text);

ParametersSection


position
A DOMString representing the position relative to the element; must be one of the following strings:

  • 'beforebegin': Before the element itself.

  • 'afterbegin': Just inside the element, before its first child.

  • 'beforeend': Just inside the element, after its last child.

  • 'afterend': After the element itself.


text
text is the string to be parsed as HTML or XML and inserted into the tree.

Visualization of position namesSection


<!-- beforebegin -->
<p>
<!-- afterbegin -->
foo
<!-- beforeend -->
</p>
<!-- afterend -->

Note: The beforebegin and afterend positions work only if the node is in the DOM tree and has a parent element.

ExampleSection


// <div id="one">one</div>
var d1 = document.getElementById('one');
d1.insertAdjacentHTML('afterend', '<div id="two">two</div>');
// At this point, the new structure is:
// <div id="one">one</div><div id="two">two</div>

NotesSection


Security ConsiderationsSection


When inserting HTML into a page by using insertAdjacentHTML be careful not to use user input that hasn't been escaped.


It is not recommended you use insertAdjacentHTML when inserting plain text; instead, use the Node.textContent property or Element.insertAdjacentText() method. This doesn't interpret the passed content as HTML, but instead inserts it as raw text.


SpecificationSection













SpecificationStatusComment
DOM Parsing and Serialization
The definition of 'Element.insertAdjacentHTML()' in that specification.
Working Draft 

Browser compatibilitySection


Update compatibility data on GitHub


























DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportFull support1Full support12Full support8Full support4
Notes

Full support7Full support4Full support2.3Full support18Full support12Full support8Full supportYesFull support4Full supportYes


Legend


Full support 
Full support
See implementation notes.
See implementation notes.


See alsoSection



  • Element.insertAdjacentElement()

  • Element.insertAdjacentText()

  • XMLSerializer: Construct a DOM representation of XML text

  • hacks.mozilla.org guest post by Henri Sivonen including benchmark showing that insertAdjacentHTML can be way faster in some cases.


(繼續閱讀...)
文章標籤

dizzy03 發表在 痞客邦 留言(0) 人氣(2)

  • 個人分類:Programming
▲top
  • 11月 02 週五 201814:41
  • [轉][VideoJs] 如何自訂video js的onclick事件,不要是預設的"暫停播放"功能

如何自訂video js的onclick事件,不要是預設的"暫停播放"功能
在初始化videojs物件時,去重新定義on click事件,並加上event.preventDefault();就可以停止預設的onclick事件。
--
 
(繼續閱讀...)
文章標籤

dizzy03 發表在 痞客邦 留言(0) 人氣(2)

  • 個人分類:Programming
▲top
  • 11月 02 週五 201814:40
  • [轉] How can I do width = 100% - 100px in CSS?

轉自 https://stackoverflow.com/questions/899107/how-can-i-do-width-100-100px-in-css
--
Modern browsers now support the:
(繼續閱讀...)
文章標籤

dizzy03 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:Programming
▲top
  • 10月 25 週四 201811:38
  • [轉] 毀掉一個年輕人最好的辦法,就是向他鼓吹財務自由


轉自 https://chinaqna.com/a/43960?fbclid=IwAR3IYzSqUV8H3reSL9WiH0XNGXBzve83IMAIp-2JGDYrm_GD7dyPd-pWnPI
--
本文來源:國館文化(微信id:guoguan5000)
(繼續閱讀...)
文章標籤

dizzy03 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:Life
▲top
  • 10月 16 週二 201810:49
  • [轉][Javascript] 使用 Video.js 在不同裝置上播放 HLS (HTTP Live Streaming) 串流影片 (mp4...等也可)


轉自 http://sweeteason.pixnet.net/blog/post/42655502
--
前言:
(繼續閱讀...)
文章標籤

dizzy03 發表在 痞客邦 留言(0) 人氣(2)

  • 個人分類:Programming
▲top
  • 10月 09 週二 201816:19
  • [轉][HTML5] 如何使用 javascript 修改網址


轉自 https://www.zoearthmoon.net/blog/program/item/1910.html
--
 
(繼續閱讀...)
文章標籤

dizzy03 發表在 痞客邦 留言(0) 人氣(2)

  • 個人分類:Programming
▲top
  • 10月 08 週一 201811:56
  • [jstree] jstree初始化時設定某些node為selected

+1
.on('ready.jstree', function (e, data) {
    data.instance.open_node(["id1","id2","id3"]);   // 帶入node的id
    data.instance.select_node(["id1","id2","id3"]);  // 帶入node的id
})
(繼續閱讀...)
文章標籤

dizzy03 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:Programming
▲top
  • 10月 08 週一 201811:54
  • [jQuery] 實現javascript object的each功能

http://api.jquery.com/jQuery.each/
var obj = {

"flammable": "inflammable",

"duh": "no duh"

};

$.each( obj, function( key, value ) {

alert( key + ": " + value );

});

(繼續閱讀...)
文章標籤

dizzy03 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:Programming
▲top
  • 10月 01 週一 201815:43
  • [轉] Suara 「星座」 - 中文歌詞

轉自 http://nakahikari.pixnet.net/blog/post/24396442
--
作詞:須谷尚子
作曲/編曲:松岡純也
歌:Suara
不負責任翻譯:nakahikari

逢いたくて でも逢えなくて もしも願いが叶うなら
  好想見你 但卻無法見面 如果可以實現願望的話
(繼續閱讀...)
文章標籤

dizzy03 發表在 痞客邦 留言(0) 人氣(5)

  • 個人分類:ACG
▲top
  • 9月 26 週三 201821:27
  • [轉][jQuery][PHP] 使用 ajax post 上傳檔案

轉自 http://wbkuo.pixnet.net/blog/post/209781556
--
 
(繼續閱讀...)
文章標籤

dizzy03 發表在 痞客邦 留言(0) 人氣(3)

  • 個人分類:Programming
▲top
«1...525354130»

熱門文章

  • (59)Ggfff
  • (228)[轉] 台鐵火車座位配置,讓你拿到票就知道靠窗還是靠道
  • (891)[Windows] 視窗最大化後發生視窗頂部或最下方出現黑色/白色/灰色空間
  • (405)[轉] 5 個免費 Bilibili 影片下載免安装線上工具推薦!
  • (524)國光號 中興號座位表
  • (506)[Word] Word「第幾頁,共幾頁」選項怎麼不見了? 其實在這裡啦~~
  • (394)[Windows] 如何將iCloud 照片 預設資料夾位置從C槽改為D槽
  • (117)[Windows] (解決)請問win10怎麼刪除微軟注音輸入法的『全形』只要『半形』
  • (90)[excel] Excel 凍結窗格、鎖定欄或列教學,固定標題不捲動
  • (63)[PhpSpreadsheet] PhpSpreadsheet設定儲存格框線樣式 Styling cell borders with PhpSpreadsheet PHP

文章精選

文章搜尋

文章分類

  • 旅遊 (3)
  • AI (2)
  • pixnet (1)
  • 騎士公主 (2)
  • 幹!MafiaWars (14)
  • 神馬三國 (39)
  • DSLR (15)
  • News (9)
  • Finance (65)
  • Estate (4)
  • Windows (78)
  • Programming (481)
  • Nihongo (18)
  • Murmur (176)
  • Application (87)
  • 3C (31)
  • Health (65)
  • ACG (73)
  • Life (111)
  • 未分類文章 (1)

最新文章

  • [轉] 3M WP4000 即淨高效濾水壺,第2代大升級!!3道過濾、1.4公升加大過濾容量、無須更換電池!
  • 健康存摺APP如何看X光片?
  • X.com 網頁版卡住錯誤排除
  • [AI] 物理小問題
  • [轉] 短期交易是零和賽局
  • [AI] 受管理的泡沫
  • [AI] 血壓計的原理
  • [AI] grok image有辦法查找產圖的歷史紀錄嗎? 包含提示詞
  • [轉] 關於在高山上失溫,27個您一定要知道的重點
  • 王永慶 山老鼠爭議?

參觀人氣

  • 本日人氣:
  • 累積人氣:

GoogleAdsense