473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Script Problems (Speed & Compatibility)

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.
Jul 23 '05 #1
2 1207
An idea just came to me. Maybe problem #2 is because after every time I
click on the link, the onload event is fired. If I'm right, how do I
avoid it?
Jul 23 '05 #2
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.

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Phil Powell | last post by:
Where can I find an online PHP form validator script library to use? I have tried hacking the one here at work for weeks now and it's getting more and more impossible to customize, especially now...
0
by: Michael Fork | last post by:
Note: I pasted the code the attachments as plain text after the message (I wasn't able to post it with an attachment...) Attached are the XSL and XML files that I am having problems with. I am...
11
by: Jonny | last post by:
Netscape 7.02 is giving me a headache with a downloaded snow script. Starting with a blank page, I inserted the script and checked it in IE 6 and Netscape 7.02. Everything worked and looked fine. A...
30
by: Toni Mcintyre | last post by:
i'm having 2 problems with the http://validator.w3.org 1. if i have: <meta http-equiv="Content-Script-Type" content="text/javascript"> then why do i need <script type=text/javascript>...
13
by: Yousuf Khan | last post by:
Hi, I have this pre-built JS routine that creates a text animation special-effect. The routine was included inside a freeware HTML editor, called AceHTML. The problem is that it seems to work only...
3
by: Razvan | last post by:
Hello, Can somebody recommend me a Java Script scroller that can scroll an i-frame ? I tried the Tigra scroller (www.softcomplex.com/products/tigra_scroller/) but sometimes it does not...
17
by: PJ | last post by:
Greetings... I have stumbled upon a small problem. I use Ajax to retrieve part of a page I need to update. I update a DIV element with the HTML contents I get from another page. It works...
2
by: starfi3ld | last post by:
I got a few errors with this script Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/starfi3ld/domains/starfi3ld.com/public_html/newreleases.php on line...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.