Javascript read html comment after closing html tag

I know that after the closing tag "html" nothing should be put. Report this to SharePoint ...

[...] </body> </html><!-- Rendered using cache profile:Public Internet (Purely Anonymous) at: 2013-06-06T12:57:10 --> 

This is what looks like SharePoint output caching debugging information. I want this hidden comment to be visible on every page. Switching to the original view and moving to the end of the file makes me tired.

In an attempt not to reinvent the wheel, I decided that the most sensible option would be to add a piece of javascript code to my main page, which copies the comment to the location I selected (on the page).

Any idea on how I can get a comment through javascript? jquery is fine.

+7
source share
2 answers

Just document.lastChild.nodeValue will do the trick.

(Suppose you run it after the DOM is ready)

change

I took the liberty of changing the code from an undefined answer :)

 $(function(){ $('body').append(document.lastChild.nodeValue); }); 

http://jsbin.com/arodiz/3/edit

+2
source

You can get the nodeValue of the Comment object and add it to the Body Element:

 $(document).ready(function() { var comment = $('html').prop('nextSibling').nodeValue; $('<div/>').html(comment).appendTo('body'); }); 

http://jsbin.com/arodiz/2/edit

+3
source

All Articles