开发者

Firefox extension data transfer to web page

I have a firefox extension that collaborates with a web page, and occasionally needs to inject data into it which the page formats and displays.

The way I do it now is :-

var element = doc.createElement("MyData");
doc.documentElement.appendChild(element);

for(....)
{
    var x = ....
    var y = ....
    var z = ....

    var row = doc.createElement("row");
   开发者_开发知识库 row.setAttribute("x", x);
    row.setAttribute("y", y);
    row.setAttribute("z", z);
    element.appendChild(row);
}

This gets really slow for 1000s of items, and some more time is spent by the page parsing the data and displaying it in HTML elements.

Is there a better way? Would it make sense to dump the entire data as a single string for example?

Thanks in advance


In my experience with regular site scripting, large HTML insertions appear to be faster if you inject raw HTML with the .innerHTML property. Perhaps that's true for extensions as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜