<div id="s">dssdfdy s
fdsf dsfsd
fdsf dsdsf
AAA BB<br>CCCC fdf fd<br>d<br>QQ
</div>
<textarea name="t" cols="44" rows="11" id="t"></textarea>
<script>
function isIE(){
if(window.navigator.userAgent.toString().toLowerCase().indexOf("msie") >=1)
return true;
else
return false;
}
if(!isIE()){
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>"?'':childS[i].innerText;
anyString += childS[i].innerText;
else if(childS[i].nodeType==3)
anyString += childS[i].nodeValue;
}
return anyString;
}
);
HTMLElement.prototype.__defineSetter__("innerText",
function(sText){
this.textContent=sText;
}
);
}
//alert(document.getElementById("s").innerText)
document.getElementById("t").value=document.getElementById("s").innerText;
</script>
在火狐里怎么正确显示换行呢?
fdsf dsfsd
fdsf dsdsf
AAA BB<br>CCCC fdf fd<br>d<br>QQ
</div>
<textarea name="t" cols="44" rows="11" id="t"></textarea>
<script>
function isIE(){
if(window.navigator.userAgent.toString().toLowerCase().indexOf("msie") >=1)
return true;
else
return false;
}
if(!isIE()){
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>"?'':childS[i].innerText;
anyString += childS[i].innerText;
else if(childS[i].nodeType==3)
anyString += childS[i].nodeValue;
}
return anyString;
}
);
HTMLElement.prototype.__defineSetter__("innerText",
function(sText){
this.textContent=sText;
}
);
}
//alert(document.getElementById("s").innerText)
document.getElementById("t").value=document.getElementById("s").innerText;
</script>
在火狐里怎么正确显示换行呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货