js代码: 复制代 代码如下: <br>window.onload = function(){ <br><PRE class=javascript name="code">if(window.navigator.userAgent.toLowerCase().indexOf("msie")==0){ //firefox innerText <br>HTMLElement.prototype.__defineGetter__( "innerText", <br>function(){ <br>var anyString = ""; <br>var childS = this.childNodes; <br>for(var i =0; i<childs.length i>if(childS[i].nodeType==1) <br>anyString = childS[i].tagName=="BR" : childS[ i].textContent; <br>else if(childS[i].nodeType==3) <br>anyString = childS[i].nodeValue; <br>return anyString <br>} <br> ); <br>HTMLElement.prototype.__defineSetter__( "innerText", <br>function(sText){ <br>this.textContent=sText; <br>} <br>); <br>};var test = document.getElementById("test");<br> <br>var innerText_s = test.innerText;<BR> <br>if( innerText_s == 未定義 ){<BR> <br>alert( test.textContent ); // Firefox<br> <br>}その他{ <br> <br>alert(test.innerText);<br> <br>};<br> <br><br> <br><br> <br>}<br> <br><br> <br><br> <br> html代码 test1 test2