Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 30th, 2006, 06:56 PM
Authorized User
 
Join Date: Jun 2006
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Browser Rendering

i have this case :
div1.style.display = "block";
div1.innerHTML = "Loading";
for(var i = 0; i < 100000000; i++)
{
     // long process
}
div1.style.display = "none";

in the above code div1 does not appear at all, i think it is
a will known issue in programming, now my question is there
a method (for example : document.update()) that force the browser to render the above script before executing the loop??

  #2 (permalink)  
Old December 30th, 2006, 08:12 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Yes, factor out the long process into a separate function and call it using window.setTimeout with a small time delay, 200ms for example. This gives the browser a chance to update the display. When the long process finishes set the div back to hidden.

--

Joe (Microsoft MVP - XML)
  #3 (permalink)  
Old December 31st, 2006, 03:58 AM
Authorized User
 
Join Date: Jun 2006
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thnx, but is there any other solutions, cuz to take the long process out
of the function will let me change the whole structure for my script,
cannot i invoke the browser to stop reading more script lines and execute
the non-executed lines first?



Similar Threads
Thread Thread Starter Forum Replies Last Post
Specific-browser Rendering by Web Controls mrf ASP.NET 2.0 Basics 0 August 24th, 2006 03:57 PM
report rendering WelshAllBlack BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 November 15th, 2005 03:08 AM
Launch default browser in a new browser window haiying Beginning VB 6 1 August 30th, 2005 05:48 PM
Programmatic Rendering drhabi BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 July 27th, 2004 06:00 PM
Events and rendering mlwallin ASP.NET 1.0 and 1.1 Basics 0 July 2nd, 2003 03:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.