Metaname - Eigenschaft
Beispiel
Gibt den Wert des Inhaltsattributs aller Meta-Elemente zurück:
var x = document.getElementsByTagName("META");
var txt = "";
var i;
for (i = 0; i < x.length; i++) {
txt = txt + "Name of "+(i+1)+". meta tag: "+x[i].name+"<br>";
}
Definition und Verwendung
Die Name-Eigenschaft legt einen Namen für die Informationen im Inhaltsattribut fest oder gibt einen Namen zurück.
Der Wert des Namensattributs hängt vom Wert des Inhaltsattributs ab.
Es gibt auch eine erweiterte Liste, die in der WHATWG Wiki MetaExtensions Page definiert ist – Jeder kann die Seite jederzeit bearbeiten, um einen neuen Typ hinzuzufügen. Keine sind offiziell akzeptiert, aber möglicherweise in der Zukunft. Weitere Informationen finden Sie auf der WHATWG Wiki MetaExtensions-Seite .
Hinweis: Wenn das http-equiv-Attribut gesetzt ist, sollte das name-Attribut nicht gesetzt werden.
Browser-Unterstützung
Property | |||||
---|---|---|---|---|---|
name | Yes | Yes | Yes | Yes | Yes |
Syntax
Geben Sie die Namenseigenschaft zurück:
metaObject.name
Legen Sie die Namenseigenschaft fest:
metaObject.name = "application-name|author|description|generator|keywords"
Value | Description |
---|---|
application-name | Specifies the name of the Web application that the page represents |
author | Specifies the name of the author of the document. Example: <meta name="author" content="Hege Refsnes"> |
description | Specifies a description of the page. Search engines can pick up this description to show with the results of searches. Example: <meta name="description" content="Free web tutorials"> |
generator | Specifies one of the software packages used to generate the document (not used on hand-authored pages) Example: <meta name="generator" content="FrontPage 4.0"> |
keywords | Specifies a comma-separated list of keywords - relevant to the page (Informs search engines what the page is about). Tip: Always specify keywords (needed by search engines to catalogize the page). Example: <meta name="keywords" content="HTML, meta tag, tag reference"> |
Rückgabewert
Type | Description |
---|---|
String | A name for the information in the content attribute |
❮ Meta-Objekt