2014-01-16 37 views
-5

我試圖谷歌爲此,但((令人驚訝)無法找到它。任何人都可以指向每個HTML標籤的數組(使用Javascript語法)嗎?我需要這個,因爲我有一個圖書館,希望我將我想要的每個標籤列入白名單(我希望所有這些標籤都是白名單)。任何人都可以指向我(或張貼)每個HTML標籤的數組

所以,換句話說,該陣列看起來像:

var htmlTags = ['a', 'base', 'br', ...] 

*快速注到潛在的閉門*

雖然這個問題並問到資源的引用,它不是要求「最喜愛的場外資源」;事實上,整個資源都包含在答案中。我真的相信這個數組可能對未來的其他人有用,所以請考慮不要關閉這個問題(據我所知,它不符合「脫離主題」的標準),並將這些HTML標籤留給其他人在未來找到。如果我找不到一個,也沒有任何評論者/回答者,那麼顯然它不是網絡上已經存在的資源。

+0

變種元素= document.getElementsByTagName(‘*’); –

+1

如果你只是想用Javascript數組語法格式化它,你可以在你喜歡的代碼編輯器中輕鬆使用宏。 – nullability

+0

@Alex Shiman好主意......除非它只在我所在的頁面上有每種類型的標籤纔有效。 – machineghost

回答

1

我去MDN,從屏幕上覆制的標籤。我取代<帶有「我替換>用」,和手動刪除的標題

["a", 
"abbr", 
"acronym", 
"address", 
"applet", 
"area", 
"article", 
"aside", 
"audio", 
"b", 
"base", 
"basefont", 
"bdi", 
"bdo", 
"bgsound", 
"big", 
"blink", 
"blockquote", 
"body", 
"br", 
"button", 
"canvas", 
"caption", 
"center", 
"cite", 
"code", 
"col", 
"colgroup", 
"content", 
"data", 
"datalist", 
"dd", 
"decorator", 
"del", 
"details", 
"dfn", 
"dir", 
"div", 
"dl", 
"dt", 
"element", 
"em", 
"embed", 
"fieldset", 
"figcaption", 
"figure", 
"font", 
"footer", 
"form", 
"frame", 
"frameset", 
"h1", 
"h2", 
"h3", 
"h4", 
"h5", 
"h6", 
"head", 
"header", 
"hgroup", 
"hr", 
"html", 
"i", 
"iframe", 
"img", 
"input", 
"ins", 
"isindex", 
"kbd", 
"keygen", 
"label", 
"legend", 
"li", 
"link", 
"listing", 
"main", 
"map", 
"mark", 
"marquee", 
"menu", 
"menuitem", 
"meta", 
"meter", 
"nav", 
"nobr", 
"noframes", 
"noscript", 
"object", 
"ol", 
"optgroup", 
"option", 
"output", 
"p", 
"param", 
"plaintext", 
"pre", 
"progress", 
"q", 
"rp", 
"rt", 
"ruby", 
"s", 
"samp", 
"script", 
"section", 
"select", 
"shadow", 
"small", 
"source", 
"spacer", 
"span", 
"strike", 
"strong", 
"style", 
"sub", 
"summary", 
"sup", 
"table", 
"tbody", 
"td", 
"template", 
"textarea", 
"tfoot", 
"th", 
"thead", 
"time", 
"title", 
"tr", 
"track", 
"tt", 
"u", 
"ul", 
"var", 
"video", 
"wbr", 
"xmp"] 

很高興我能做到的清潔30秒向上

+0

非常感謝。 – machineghost

1

使用規範即http://www.w3.org/TR/html5/index.html#elements-1

有一個表。 Cut'n'paste它

編輯

就突出顯示錶。 Cut'n'pasterto記事本+ +正則表達式刪除後的第一空間 - 有

a 
abbr 
address 
area 
article 
aside 
audio 
b 
base 
bdi 
bdo 
blockquote 
body 
br 
button 
canvas 
caption 
cite 
code 
col 
colgroup 
data 
datalist 
dd 
del 
details 
dfn 
dialog 
div 
dl 
dt 
em 
embed 
fieldset 
figcaption 
figure 
footer 
form 
h1, 
head 
header 
hr 
html 
i 
iframe 
img 
input 
ins 
kbd 
keygen 
label 
legend 
li 
link 
main 
map 
mark 
meta 
meter 
nav 
noscript 
object 
ol 
optgroup 
option 
output 
p 
param 
pre 
progress 
q 
rp 
rt 
ruby 
s 
samp 
script 
section 
select 
small 
source 
span 
strong 
style 
sub 
summary 
sup 
table 
tbody 
td 
textarea 
tfoot 
th 
thead 
time 
title 
tr 
track 
u 
ul 
var 
video 
wbr 
+0

感謝您的建議。但不幸的是,它更像是「複製/粘貼整個表,編寫某種正則表達式來刪除所有其他列,運行該正則表達式,修復任何正則表達式的問題,再試一次......」如果存在,我會希望能夠使用已經是數組格式的列表。 – machineghost

+0

感謝您編輯的答案;我提高了它,但是@epascarello在接受方面擊敗了你(幾乎沒有)。 – machineghost

相關問題