JS Code:
Copy Code code as follows:
<script>
Window.onload = function () {
<pre class=javascript name= "code" >if (Window.navigator.userAgent.toLowerCase (). IndexOf ("MSIE") ==0) {// Firefox innertext
htmlelement.prototype.__definegetter__ ("InnerText",
function () {
var anystring = "";
var ChildS = this.childnodes;
for (var i=0; i<childs.length; i++) {
if (childs[i].nodetype==1)
AnyString + = childs[i].tagname== "BR"? ' \ n ': childs[i].textcontent;
else if (childs[i].nodetype==3)
AnyString + = Childs[i].nodevalue;
}
return anystring;
}
);
htmlelement.prototype.__definesetter__ ("InnerText",
function (stext) {
This.textcontent=stext;
}
);
};</pre>var test = document.getElementById ("Test");<br>
var innertext_s = test.innertext;<br>
if (innertext_s = = undefined) {<br>
alert (test.textcontent); Firefox<br>
}else{<BR>
Alert (Test.innertext);<br>
};<br>
<BR>
<BR>
}<br>
<BR>
<BR>
</script><BR>
<PRE></PRE>
<P><BR>
</P>
<p>html Code </P>
<p><div id= "Test" ><BR>
<span style= "color:red" >test1</span> test2<br>
</div><BR>
</P>