谁能优化具体贴子显示中对5.0版本ie的现实界面作的处理???
蝈蝈俊 2002-04-25 10:03:43 函数在:
http://www.csdn.net/expert/xsl/2.xsl
其中有段对5.0换行,字符长度作限制的javascript函数
起始调用是:
function checkie()
5.0下效率特别差,你有没有啥优化的方法??
函数如下:
function Scan(element)
{
var coll=element.all;
for(var i=0;i<coll.length;i++)
{
//alert(coll.item(i).name);
TestElement(coll.item(i));
}
}
function TestElement(item)
{
try
{
var className=item.className.toLowerCase();
if(className == "neadupdate")
{
Handle(item);
}
if(className == "withbreaks")
{
change(item);
}
}
catch(x)
{
return;
}
}
function change(element)
{
var infostr = element.all.item(0).innerHTML;
while (infostr.indexOf("\r\n") >= 0)
{
infostr = infostr.replace("\r\n","<br>");
}
while (infostr.indexOf(" ") >= 0)
{
infostr = infostr.replace(" "," ");
}
while (infostr.indexOf("\t") >= 0)
{
infostr = infostr.replace("\t"," ");
}
//alert(infostr);
infostr = "<table width='580'><tr><td>"+infostr+"</td></tr></table>";
//alert(infostr);
element.innerHTML = infostr;
}
function Handle(element)
{
element.style.tableLayout = "auto";
//alert(element.innerHTML);
}
function checkie()
{
//Scan(document);
//如果浏览器版本小于5.5
if (GetIEVersion())
{
if (GetIEVersion() < 5.5)
{
Scan(document);
return;
}
}
else
{
Scan(document);
return ;
}
}