您的位置:首页 > 运维架构

vml实现web topo原型(9) - 性能改进

2010-03-22 16:51 113 查看
对于html而言,页面元素的数量会影响页面显示的性能。
在前面生成文字的时候,我们使用的是文本路径textpath元素,它包含了line、path/textpath三个vml元素。在不需要特效的时候,有些浪费。我们只需要textbox一个元素就足够了。
//创建一个文本框
function createTextb(top,left,textCon,color){
var textbox=document.createElement("textbox");
//textbox.innerHTML="<div style="text-align:center" mce_style="text-align:center">"+textCon+"</div>";
textbox.innerText=textCon;
//textbox.inset="5pt,5pt,5pt,5pt"
textbox.style.zIndex="100";
textbox.style.top=top;
textbox.style.left=left;
textbox.style.width=300;
textbox.style.fontfamily="宋体";
textbox.style.fontSize="13px";
textbox.style.color=color;
textbox.style.fontWeight="bold";
textbox.style.textAlign="center";
textbox.style.position="absolute";
//textbox.style.text-align="center";

return textbox;
}


相应的设备创建函数需要修改

var namebox=createTextb((height+height/3),(width/2-150),name,"black");
元素的类型可能也会有影响。经过测试,div和texbox的性能差别可以忽略不计。可以认为textbox就是对div的简单封装,可以替代使用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: