Not sure what you mean by slow. Seemed to work really fast with IE 6.0.
Anyway in general string concatenation can be slow and before IE 6.0 setting
the innerHTML property was pretty slow and I think is still slow for Mozilla
compared to using the DOM methods. But I may be out of date with this.
First I would recommend altering the code to use the DOM methods for element
creatation rather than using innerHTML. But if you want to use innerHTML the
faster way to perform string concatenation is to add the strings to an Array
and then perform an Array.join();
so
[snip]
var content = new String; // stores the table for output
content = "<table border='0' width='432' height='432' cellspacing='0'
cellpadding='0'>";
// first border row
content += "<tr height='9'>";
[/snip]
would become
var content = new Array();
content.push("<table border='0' width='432' height='432' cellspacing='0'
cellpadding='0'>");
// first border row
content.push("<tr height='9'>");
..
..
..
showContentObj.innerHTML=content.join();
"Adelson Anton" <ad*****@mail.ru> wrote in message
news:40******@duster.adelaide.on.net...
Greetings fellow coders. Please check this page for a code which
rearranges chess cells:
http://s95005072.onlinehome.us/blog/Chess/chess.htm
There are 2 problems:
1. It takes quite a bit for the function to run each time. I don't know
how to speed it up further.
2. The function runs twice on mozilla browsers for some reason.
Any help is greatly appreciated. And hold your flames, this is my first
usable JS script.