<!DOCTYPE HTML><HTML><Head> <MetaCharSet= "Utf-8"> <title>JS Bin</title> <Scripttype= "Text/javascript">window.onload= function(){ varRow=Document.createelement ("TR"); document.getElementById ("tbody"). appendchild (row); }; </Script></Head><Body> <table></table> <tbody id= "tbody"></tbody> </Body></HTML>
Each browser will report a different error (caused by the wrong tag nesting , need to put tbody in the table)
+| IE 6,7,8 | A method or property access was called unexpectedly. | 0 |+| IE 9 cannot get the value of the property "AppendChild": object is null or undefined | 0 |+| IE | Unable to get properties for undefined or null reference "AppendChild" | 0 |+| Chrome | Uncaught Typeerror:cannot Call method ' appendchild ' of null | | +| Safari 6 | TypeError: ' null ' is not a object (evaluating ' document.getElementById ("Tbody"). AppendChild ') | | +| Firefox 21 | TypeError:document.getElementById (...) is null | | +| Opera | uncaught exception:TypeError:Cannot convert ' document.getElementById ("tbody") ' to Object | |
Second, Li node set the Value property (you can set other properties instead)
<!DOCTYPE HTML><HTML><Head> <MetaCharSet= "Utf-8"> <title>JS Bin</title><Scripttype= "Text/javascript">window.onload= function() {document.getElementById ("btn-test"). onclick = function(){ varul=Document.createelement ("ul"); varLi=Document.createelement ("Li"); //The following two lines of code will trigger an exception //Li.value = "one";li.setAttribute("value"," One"); Ul.appendchild (LI); Document.body.appendChild (UL); }; };</Script></Head><Body> <button id= "btn-test"> Click Start Test </button > </Body></HTML>
Known IE6, IE7 can cause the browser to crash .