将下面的脚本保存成 innerSupport.js 文件
function isIE(){
if (window.navigator.userAgent.toString().toLowerCase().indexOf("msie") >=1)
return true;
else
return false;
}
if(!isIE()){ //firefox innerText define
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].innerText;
else if(childS[i].nodeType==3)
anyString += childS[i].nodeValue;
}
return anyString;
}
);
HTMLElement.prototype.__defineSetter__( "innerText",
function(sText){
this.textContent=sText;
}
);
}
建立一个测试页面index.html
<HTML>
<HEAD>
<META http-equiv='Content-Type' content='text/html; charset=gb2312'>
<TITLE> simple IE only</TITLE>
<script src='innerSupport.js'></script>
</HEAD>
<BODY>
<div id="aaaa">123asd
</div>
<script language="javascript" >
alert(document.getElementById("aaaa").textContent)
alert(document.getElementById("aaaa").innerText)
</script>
</BODY>
</HTML>
看看效果!
(2)document.form1.submit(); 只有写成这样 在firefox能使用!
(3)self.parent.window.frames["iframe1"].location.href=url;使用iframe实现无刷新,
(4)http://www.winliuxq.com/?action=show&id=121
(5). parentElement 获取对象层次中的父对象。
parentNode 获取文档层次中的父对象。
childNodes 获取作为指定对象直接后代的 HTML 元素和 TextNode 对象的集合。
children 获取作为对象直接后代的 DHTML 对象的集合。
parentNode和parentElement功能一样,childNodes和children功能一样。但是parentNode和childNodes是符合W3C标准的,可以说比较通用。而另外两个只是IE支持,不是标准,Firefox就不支持
(6) JS替换回车换行符
function repstr(str)
{
return str.replace(/\r\n/ig,"<br/>")
}