How to append html end of body tag

Sponsors

I created the following script putting the html at the end of body tag.

If you are using or following web 2.0(Table less HTML) standards for creating the HTMLs then this script will work 100%

Just Put this script in your HTML and see the html source. You will able to see the div id named “kapil” with the test content.


<script type=’text/javascript’>
var kapil = document.createElement(‘div’);
kapil.id = ‘form_kapil’;
var all_divs = document.getElementsByTagName(‘div’);
if (document.body.firstChild){
document.body.insertBefore(kapil, all_divs[all_divs.length] );
} else {
document.body.appendChild(kapil);
}
var oldHTML = document.getElementById(‘form_kapil’).innerHTML;
var newHTML = “test content”;
//document.getElementById(‘form_kapil’).innerHTML = newHTML;
var all_divs = document.getElementsByTagName(“div”);
//alert(all_links[all_links.length - 1].innerHTML);
all_divs[all_divs.length - 1].innerHTML = newHTML;
</script>

Have fun!

Incoming search terms:

You may like following Articles!

This entry was posted in JavaScript and tagged by Wordpress API. Bookmark the permalink.

About Wordpress API

API means Application Program interface. In Wordpress API we are giving all the information about wordpress API. We worked for many wordpress plugins and themes. We have expertise in PHP, Databases, Graphic Design, Ruby on Rails, Java, Wordpress, Drupal and many CMS. We always give you the best solutions about wordpress and other related topics in This Blog. We will give you always fresh tips and tricks and techniques about wordpress in this blog.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>