• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to force a browser to redraw ?

 
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any way to force a browser to redraw the page or perhaps even a specific element? I have page which contains a table which contain a cell that may overflow. I embedded a DIV in the table cell to allow for the overflow. It works great in IE and Safari (Windows).

However, in Firefox and Opera, it does not. Using info from a previous post in this forum, I attempt to dynamically set the DIV height in Firefox/Opera. This works in both Firefox and Opera but, after the page has been loaded in Firefox, The cell retains it original height (as laid out originally by Firefox) AFTER the DIV height has been set. If I resize the page, Firefox will correctly resize the table cell/div but it will not do so on a page load. How do I force Firefox to redraw in the onload event?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you should watch with onresize and call the code that sets the height of the div again like you do for onload.

Eric
 
Jay Damon
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I am calling the same function in my onload script as is attached to window.onresize. My point is that Firefox does not resize when executed during page load. It sets the DIV height correctly (confirmed) but does not redraw the element until an onresize event is fired. I might add that I have tried setting the TD height as well to no avail. Once a resize occurs, the page elements are redrawn and appear as they should. I have to set the DIV height for Opera as well and, once the DIV height is set, the affected elements are redrawn and the page appears as it should.

This is only a problem in Firefox (2.0.0.11) and only on page load. Curiously, if I use the Web Developer tools to attempt to outline the TD/DIV elements in the page, an onresize event is apparently triggered and again Firefox renders the page as it should.

So my question is again is how to force a redraw? Right now, I'm thinking that I should just change some other arbitrary element in an attempt to trigger a redraw.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like a timing issue. What is the line you are using to change the div?

Eric
 
Jay Damon
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it just starting working. The only thing I did was close Firefox and restart it. Issue resolved I guess. Thanks for your help Eric!
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wondering if there was a caching issue or something like that...You never know with JavaScript. LOL...

If it acts up again, you might want to look at adding a few millisecond delay after onload. Seems like that helps someties with things that do not get built right. I have had to use that little hack myself a few times.

Eric
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic