Bomb-proof document retreiver


/ Published in: JavaScript
Save to your folder(s)

This will get the document's body in a very agreeable manner - it returns the first div on the page if there is no body (hey it can happen).

Adapted from code by Scott Schiller


Copy this code and paste it in your HTML
  1. getDocument: function() {
  2. return(document.body?document.body:(document.documentElement?document.documentElement:document.getElementsByTagName('div')[0]));
  3. },

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.