Header of the access page of the current page in javascript [no ajax]

How to view page titles of loaded page using javascript.

Is there something where I can perform

eg window.pageHeaders['session'] 

Note. I'm not talking about loading an Ajax page.

+8
javascript html
source share
2 answers

Take a look at jsfiddle .

Link to this question .

This Raja response will receive the page headers for the current page.

 var req = new XMLHttpRequest(); req.open('GET', document.location, false); req.send(null); var headers = req.getAllResponseHeaders().toLowerCase(); alert(headers); 
+3
source share

are you doing something like this please show us an example implementation.

  <!--Save Headers--> <?php $currentHeaders = json_encode( getallheaders() ); ?> <!--Create Output Container--> <div id="output"></div> <!--Show Headers--> <button onclick="showheaders()">show headers</button> <!--Javascript Ugliness--> <script> function showheaders(){ var headers = <?php echo $currentHeaders; ?>; // Collect your goodies here eg: var goodies = headers['proxy-authenticate']; console.log("Headers", headers); // See the output on screen? var output = document.getElementById('output'); output.innerHTML = JSON.stringify( headers ); } </script> 
0
source share

All Articles