0

I'm using this JS to create progress bars on my website : http://www.webappers.com/progressBar/

On some pages, I use those bars in tables. But for an unknown reason, the first time I load a page containing a table, only the bars are (partially) displayed, the rest of the document isn't rendered :

empty progress bar

This is when the table has only 1 row, if there are many rows I then have many of these juxtaposed and the rest of the document is still empty.

Now if I load the page again (typing the URL by hand), it works fine, the table and all the document is rendered as it should. But if I refresh the page (CTRL+R), again the problem appears.

Any idea what is happening ? Using JS debugger (Chrome's one), I can see that the "display" function is called and the "document.write" for the bars is running ok. It just seems that after this the document rendering suddenly stops. No JS error is happening.

As suggested in comments, I should remove the "document.write" and replace it with something else. Any idea what will do the trick ?

ack__
  • 913
  • 1
  • 14
  • 39
  • I don't, it's the "display" function from the progress.js file that uses it. Do you suggest I should change it to something else ? – ack__ Oct 19 '12 at 07:40
  • Yes. Especially because that script does pollute the global namespace with its [useless] functions. And yes, `document.write` called (through `display`) after DOM ready crashes your site – Bergi Oct 19 '12 at 07:45
  • Any hint what other function I should use to display it then ? I'm not really experienced at JS. I planned to use a element.innerHTML but the progress bar is displayed with , then if I just modify the HTML for the target element, the script won't be rendered right ? – ack__ Oct 19 '12 at 07:55
  • possible duplicate of [JavaScript - what are alternatives to document.write?](http://stackoverflow.com/questions/4537963/javascript-what-are-alternatives-to-document-write) – Bergi Aug 08 '13 at 02:57

1 Answers1

0

Well, if you don't know about Javascript, just ask your favourite search engine for a more recent script of the same type. One that uses the DOM. I'm sure there are plenty out there.

DanMan
  • 11,323
  • 4
  • 40
  • 61
  • I'm more inclined in learning something about JS rather than blindly switching tools. – ack__ Oct 19 '12 at 10:45
  • I don't know the script, but getting rid of `document.write` usually means a lot of re-written code, so you're probably better off looking for something more up-to-date. – DanMan Oct 19 '12 at 15:47