Snippets v2

Languages
My Snippets

innerHtml Cross Browser Login or Register to Bookmark this snippet

Description Javascript

xInnerHtml is a cross-browser version of .innerHtml

e can be id of element as string or object reference.

Also requires xGetElementById (also available on this site).

The Code Download
  1. function xInnerHtml(e,h){
  2.     if(!(e=xGetElementById(e)) || !xStr(e.innerHTML)) return null;
  3.     var s = e.innerHTML;
  4.     if (xStr(h)) {e.innerHTML = h;}
  5.     return s;
  6. }
  7.  
  8. function xStr(s){
  9.     for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  10.     return true;
  11. }
Credits Contact JC

Added by JC on 11th November, 2007

Comments

There are no comments about this snippet.

Post Comment HTML is allowed

You must be registered and logged in to post a comment.

Login here to post a comment