Javascript examples for DOM HTML Element:Meta
The httpEquiv property sets or gets an HTTP header in the content attribute.
The http-equiv attribute can be used to simulate an HTTP response header.
Some commonly used HTTP-header values are:
Value | Description |
---|---|
content-type | Sets the character set for the contents of the document. Example: <meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
default-style | Sets the preferred style sheet to use. Example: <meta http-equiv="default-style" content="the documents preferred stylesheet"> |
refresh | Defines a time interval for the document to refresh itself. Example: <meta http-equiv="refresh" content="300"> |
Type | Description |
---|---|
String | Information about the HTTP response message header |
The following code shows how to return the HTTP header for the information in the content attribute:
<!DOCTYPE html> <html> <body> <meta http-equiv="content-type" content="text/html"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/* ww w .j a v a 2s. c om*/ var x = document.getElementsByTagName("META")[0].httpEquiv; var y = document.getElementsByTagName("META")[0].content; document.getElementById("demo").innerHTML = x + " " + y; } </script> </body> </html>