I know you shouldn't put anything after the closing 'html' tag. Tell SharePoint about it...
[...]
</body>
</html><!-- Rendered using cache profile:Public Internet (Purely Anonymous) at: 2013-06-06T12:57:10 -->
This is what the SharePoint output caching debug information looks like. I want this hidden comment to be visible on every page. Switching to source view and going to the end of the file makes me tired.
In an effort to not reinvent the wheel I figured it would be the smartest choice to add a piece of javascript code to my masterpage which copies the comment to a location (within the page) of my choosing.
Any idea on how I get hold of the comment via javascript? jquery is ok.
An HTML comment begins with <! –– and the comment closes with ––> . HTML comments are visible to anyone that views the page source code, but are not rendered when the HTML document is rendered by a browser.
The HTML Comment Tag Comments in HTML start with <! -- and end with --> .
To “comment out” in HTML, simply place the < ! ╌ ╌> tags around the code you want to hide. These tags will tell browsers not to render this code on the front end. Commenting out has two main purposes.
The comment tag is used to insert comments in the source code. Comments are not displayed in the browsers. You can use comments to explain your code, which can help you when you edit the source code at a later date.
You can get the nodeValue
of the Comment
Object and append it to Body
Element:
$(document).ready(function() {
var comment = $('html').prop('nextSibling').nodeValue;
$('<div/>').html(comment).appendTo('body');
});
http://jsbin.com/arodiz/2/edit
Simply document.lastChild.nodeValue
will do the trick.
(Assuming you run it after the DOM is ready)
I took the liberty of modifying the code from undefined's answer :)
$(function(){
$('body').append(document.lastChild.nodeValue);
});
http://jsbin.com/arodiz/3/edit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With