473,657 Members | 2,585 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

temporarily disable IE repaint?

I have some code that looks like this:

var options = document.sform. files.options
for (var i = 0; i < options.length; i++) {
options[i].selected = true
}

As it loops you can see the options scroll by while IE renders each
one. For a couple hundred options this is okay, but I need to handle
up to 10,000. (Long story.) Is there a way to hint to IE that "hey,
I'm going to do a lot of these, wait until we're all done before
repainting?" Or is there a better way to speed things up?

Sample html:

<html>
<body>
<script language=javasc ript>
function selectall() {
var options = document.sform. files.options
for (var i = 0; i < options.length; i++) {
options[i].selected = true
}
}
</script>

<form name=sform>
<select name=files multiple size=10>
<option>foo
<!-- repeat option line a few thousand times -->
</select>
<input type=button onclick="select all()" value="select">
</form>

</body>
</html>

Thanks,

-Jonathan

Jul 23 '05 #1
6 3378
Jonathan Ellis wrote:

Hi,
I have some code that looks like this:

var options = document.sform. files.options
for (var i = 0; i < options.length; i++) {
options[i].selected = true
}

As it loops you can see the options scroll by while IE renders each
one. For a couple hundred options this is okay, but I need to handle
up to 10,000. (Long story.) Is there a way to hint to IE that "hey,
I'm going to do a lot of these, wait until we're all done before
repainting?" Or is there a better way to speed things up?


I don't think you can prevent the repainting in IE, but you could try
hiding the select box, select the options and show it again - this would
give interesting results in IE, which AIUI you're only concerned with.

Other browsers wouldn't benefit from this approach though, you'd have to
use other techniques (for instance working on orphaned nodes) - or more
simply not have a select box with 10,000 entries (short story).
<script type="text/javascript">
var SelectOptions = (function(){
var selectObj=null;
var options=[];

function selectOptions(b Select){
selectObj.style .visibility="hi dden";
setTimeout(
function(){
for(var ii=options.leng th; ii--;)
options[ii].selected=bSele ct;
selectObj.style .visibility="vi sible";
},
1
);
}

return {
init : function() {
selectObj=docum ent.forms["sform"].elements["files"];
for(var opt=selectObj.o ptions, ii=opt.length; ii--;)
options[ii]=opt[ii];
},
selectAll : function() {
options[0].selected=true; //to speed IE
selectOptions(t rue);
},
selectNone: function() {
selectOptions(f alse);
}
};
})();

window.onload = function() {
SelectOptions.i nit();
}
</script>

<form name="sform">
<script type="text/javascript">
var buf=["<select name='files' multiple='multi ple' size='10'>"];
for(var ii=0; ii<10000; ii++)
buf[buf.length]="<option>fo o<\/option>";
buf[buf.length]="<\/select>";
document.write( buf.join(""));
</script>
<input type=button onclick="Select Options.selectA ll()" value="1">
<input type=button onclick="Select Options.selectN one()" value="2">
</form>
HTH,
Yep.

Jul 23 '05 #2
On Thu, 09 Jun 2005 17:35:57 +0200, Yann-Erwan Perio <ye*@invalid.co m>
wrote:
I don't think you can prevent the repainting in IE,


screen.updateIn terval

but use with immense caution, it's almost never sensible to do it.

Jim.
Jul 23 '05 #3
Jim Ley wrote:
I don't think you can prevent the repainting in IE,
screen.updateIn terval

but use with immense caution, it's almost never sensible to do it.


Ahah, I didn't know this one, it's a funny property:-)

I can't manage to make it work in regards of the OP's needs, though (it
seems that the selection is not considered as repainting, maybe due to
select elements being windowed controls - or my test cases being
completely inadequate, it's been time since I haven't programmed).
Cheers,
Yep.
Jul 23 '05 #4
Jonathan Ellis wrote:
I have some code that looks like this:

var options = document.sform. files.options
for (var i = 0; i < options.length; i++) {
options[i].selected = true
}

As it loops you can see the options scroll by while IE renders each
one. For a couple hundred options this is okay, but I need to handle
up to 10,000. (Long story.) Is there a way to hint to IE that "hey,
I'm going to do a lot of these, wait until we're all done before
repainting?" Or is there a better way to speed things up?

Sample html:

<html>
<body>
<script language=javasc ript>
function selectall() {
var options = document.sform. files.options
for (var i = 0; i < options.length; i++) {
options[i].selected = true
}
}
</script>

<form name=sform>
<select name=files multiple size=10>
<option>foo


A closing tag is required for option elements, perhaps that was slowing
you down. The following selects all options in about 2 seconds in IE,
Firefox takes about 20 seconds (your performance may vary...).

A do..while does not seem to offer any significant benefit in
this case (not to mention that I'd love to know the point of 10,000
options).
<form action="" name="formA">
<select multiple name="bigSelect ">
<script type="text/javascript">
var s = document.forms['formA'].elements['bigSelect'];
for ( var i=0; i<10000; i++ ){
document.write( "<option>Op tion " + i + "</option>");
}
</script>
</select>
<input type="button" value="Select do..while" onclick="
var opts = this.form.eleme nts['bigSelect'].options;
var x, i=0;
var s = new Date()
if ( ( x = opts[i] ) ){
do {
x.selected = true;
} while ( ( x = opts[++i] ) )
}
var f = new Date();
alert( (f-s));
">

<input type="button" value="Select for..length" onclick="
var options = this.form.eleme nts['bigSelect'].options;
var s = new Date()
for (var i = 0; i < options.length; i++) {
options[i].selected = true
}
var f = new Date();
alert( (f-s));
">
</form>

--
Rob
Jul 23 '05 #5
On Fri, 10 Jun 2005 07:31:32 GMT, RobG <rg***@iinet.ne t.auau> wrote:
Jonathan Ellis wrote:
A closing tag is required for option elements, perhaps that was slowing
you down.


Nope, closing option tag is optional in HTML, IE only understands HTML
of course.

Jim.
Jul 23 '05 #6
Jim Ley wrote:
On Fri, 10 Jun 2005 07:31:32 GMT, RobG <rg***@iinet.ne t.auau> wrote:

Jonathan Ellis (actually RobG) wrote:
A closing tag is required for option elements, perhaps that was slowing
you down.

Nope, closing option tag is optional in HTML, IE only understands HTML
of course.


Dang, I even checked the spec - but the 'option' link from the HTML
elements index takes you to the header for select, optgroup and
option so I actually read the requirements for select, not option.
--
Rob
Jul 23 '05 #7

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

Similar topics

6
10471
by: Tuong Do | last post by:
Hi, I am going to insert a large amount (200,000 records) of data into a table Is there a way that I can temporarily disable the log? so that the insertion run faster Thanks in advance
2
1697
by: G.Ashok | last post by:
Hi, Is there a way to suspend the background compilation of VB.NET in VS.NET IDE? I want to define a macro key to temporarily suspend and resume the background compilation. Regards, ....Ashok
3
1605
by: jojobar | last post by:
Hello, I am trying to localize an existing application (asp.net 2.0). using implicit as well as explicit localization. Asp.net 2.0 uses App_LocalResources folder for implicit localization. When this happens the tag values for Text, ToolTip etc. are not used from the aspx file but read from the resource files. The problem is that most developers works on the aspx files to make and view changes.
9
8040
by: Armando | last post by:
I have an app (A2000) where I am letting the user move an object on the screen. I use the OnClick for a command button event to modify the object's Top (or Left) properties, but you can only click slowly. That is, every other click is ignored, because Access is seeing a double click event. I would put the same code there, except I'm also using the SHIFT key (during mouse click) to cause bigger moves, and there's no SHIFT flag for the...
4
16851
by: Marc Solé | last post by:
Hello everybody, I have a little "problem". I have a DataGridView that is loaded automatically by code sometimes, and manually by the user other times. When the user introduces data in the DataGridView, there are some events that control the introduced data for any errors the user can do. That's OK. But when the data is loaded automatically, it is supposed that this data is
4
6628
by: Jon Slaughter | last post by:
Is there any method to temporarily disable focus changing?(I assume only method is tab or mouse?) This problem has been tieing me up for a while and nothing seems to work. The only thing that I *know* will work is to disable all tab stops on all controls. This brute force method doesn't seem like a good idea though. What I wanted to do was take control the control enter/leave and mouse enter/leave and "switch back" the focus when it is...
37
5039
by: Vince C. | last post by:
Hi all. I've installed Bloodshed Dev-C++ on a Windows 2000 SP4 machine. I'm using MinGW 3.4.2. I'd like to temporarily disable standard functions to write to stderr, i.e. for instance redirect stderr to a temporary file (or /dev/null but is there an equivalent under Windows? Is it "nul:") and then to *restore* the default stderr so that standard library functions that write to stderr produce output again.
3
5065
hsriat
by: hsriat | last post by:
How can I temporarily disable vertical scrollbar? I have replaced confirmation boxes and alert boxes with inlay popup DIVs. But while they are on the screen, I need to disable scrollbar of the page so that user may not access the main page (just like in conformation boxes). Also I need to disable the main page leaving that popup DIV. Scrollbar is the main issue. How can I do it?
0
1948
by: milkay | last post by:
<I have code that uses 2 images> the program creates a window and then when u press play, it removes all components in the container. then, i add a NewPanel object. i add mouse listeners and all in all, you should see an image following your mouse. BUT. its only seen after you press play and then resize the window. this leads me to conclude that theres a problem with repaint(). can someone please help? thanks. heres my code: (EnemyShip...
2
2880
by: labmonkey111 | last post by:
I have a form that takes several seconds to run the javascript needed to prepare the form for PHP (selecting all items in a Select Multiple). Since it takes so long, I want to disable the Submit button and Change the text to "Please Wait..." I have the code done, and it sorta works. FireFox3 does not seem to update the page until all JavaScript is done executing, so after the few seconds of nothing happening, then the button is disabled and...
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7333
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.