How to append html end of body tag


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 “purab” with the test content.
<script type=’text/javascript’>
var purab = document.createElement(‘div’);
purab.id = ‘form_purab’;
var all_divs = document.getElementsByTagName(‘div’);
if (document.body.firstChild){
document.body.insertBefore(purab, all_divs[all_divs.length] );
} else {
document.body.appendChild(purab);
}
var oldHTML = document.getElementById(‘form_purab’).innerHTML;
var newHTML = “test content”;
//document.getElementById(‘form_purab’).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!

Advertisements
This entry was posted in PHP and tagged by Purab Kharat. Bookmark the permalink.

About Purab Kharat

I am WordPress and Drupal Architect. I worked on many technologies like Ruby on Rails, Flex, PHP etc... I am Purab Kharat from India, Pune. I love to play chess and listen music and read books. I work in SY Smartsourcing Global Pvt Ltd in Princeton, NJ, USA. Now I am living at Plainsboro, 164 Hampshire Drive, Princeton Meadows, NJ. I have more then Ten years experience in Web Application Development (Specially in Php 5.0, Ruby on Rails, Mysql 5.0, RIA, Wordpress, Drupal, Joomla, Ecommerce)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s