Javascript DOM HTML Meta httpEquiv Property get

Introduction

Return the HTTP header for the information in the content attribute:

var x = document.getElementsByTagName("META")[0].httpEquiv;

Click the button to return the value of the http-equiv attribute.

View in separate window

<!DOCTYPE html>
<html>
<body>

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*  w  ww.j  av a2  s .c o  m*/
  var x = document.getElementsByTagName("META")[0].httpEquiv;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

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.

The value of the http-equiv attribute depends on the value of the content attribute.

Some commonly used HTTP-header values are:

Value
Description
content-type


the character set for the contents of the document.
Example:
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
default-style


the preferred style sheet to use.
Example:
<meta http-equiv="default-style" content="the documents preferred stylesheet">
refresh


a time interval for the document to refresh itself.
Example:
<meta http-equiv="refresh" content="300">



PreviousNext

Related