<!DOCTYPE html PUBLIC "-//W3C//DTD xhtml 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> </head> <body> <div id="Container" > <table > <tbody id="tb"> </tbody> </table> <div id="clone"> <img class="PageImg" /> <br /> <a href="empty" mce_href="empty" class="PageHref">empty</a> </div> </div> <mce:script language="javascript"><!-- var strSectionNames = ["www.yahoo.com","www.google.com","news.tom.com"] var nLen = arrSections.length; var oTB = document.getElementById("tb"); var oTR = null; var oTD = null; var oClone = document.getElementById("clone"); var oContent = null; var oPageImage = null; var oPageHref = null; nLen = 6; for( var i=1; i<=nLen; i++ )//去除第一个空字符串 { if( (i-1)%3 == 0 ) { oTR = null; oTB.appendChild( oTR = document.createElement("tr") ); } oTD = null; oTR.appendChild( oTD = document.createElement("td") ); oContent = null; oContent = oClone.cloneNode(true); oContent.style.display = "block"; oPageImage = null; oPageHref = null; oPageImage = oContent.getElementsByTagName("img")[0]; oPageHref = oContent.getElementsByTagName("a")[0]; //关注这里: oPageHref.innerText = arrSections[i]; oPageHref.href = "http://www.163.com"; oTD.appendChild( oContent ); oPageHref = oPageImage = oContent = null; } arrSections = null; strSectionNames = null; nLen = null; oTR = null; oTD = null; // --></mce:script> </body> </html>
这其中对一个链接点的操作:
oA.innerText = "www.my.com";
oA.href = "www.other.com";
然后结果 oA.innerText 自动变为 www.other.com
如果 oA.href 不是 www开头, 或者 oA.innerText不是 www开头, 就不会有这种情况.
oA.href = "www.other.com";
oA.innerText = "www.my.com";
就没有问题了.
很奇怪!