Thuộc tính meta name
Thí dụ
Trả về giá trị của thuộc tính nội dung của tất cả các phần tử meta:
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>";
}
Định nghĩa và Cách sử dụng
Thuộc tính name đặt hoặc trả về tên cho thông tin trong thuộc tính content.
Giá trị của thuộc tính tên phụ thuộc vào giá trị của thuộc tính nội dung.
Ngoài ra còn có một danh sách mở rộng được xác định trong Trang MetaExtensions của GÌWG Wiki - Bất kỳ ai cũng có thể tự do chỉnh sửa trang bất kỳ lúc nào để thêm một kiểu mới. Không có cái nào được chính thức chấp nhận, nhưng có thể trong tương lai. Để biết thêm thông tin, hãy truy cập trang GÌWG Wiki MetaExtensions .
Lưu ý: Nếu thuộc tính http-equiv được đặt thì không nên đặt thuộc tính name.
Hỗ trợ trình duyệt
Property | |||||
---|---|---|---|---|---|
name | Yes | Yes | Yes | Yes | Yes |
Cú pháp
Trả lại thuộc tính tên:
metaObject.name
Đặt thuộc tính tên:
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"> |
Giá trị trả lại
Type | Description |
---|---|
String | A name for the information in the content attribute |
❮ Đối tượng Meta