How Do You Stop Browser From 'hourglassing' When Javascript Is DONE (stop Throbber)?
Writing a small HTML web page with some very simple Javascript in it, I noticed that after it was done, it kept the circle spinning (firefox). I've seen that many times on other p
Solution 1:
After calling document.write()
, you must call document.close()
if the document was previously not closed.
Basically, this happens:
- The page is getting parsed
- Scripts are processed
- Page is "closed" (
document.close()
)
If document.write()
is called within step 2, it will be finished in step 3.
Beyond step 3, if you call document.write
, you're opening the page again, but the page won't close itself in FF (not sure about others). You've to close it by calling document.close()
.
I discovered this when I needed to open a window and write into it quickly in FF.
var win = window.open();
win.document.write("something");
// the next line is required to finish the page
win.document.close();
The same applies to your case:
<script type="text/javascript">
function calculate()
{
var grade = document.getElementById("grade").value.toUpperCase();
switch (grade)
{
case "A":
document.write("Outstanding Achievement");
break;
// removed some cases
case "F":
document.write("Failing Grade");
break;
}
// finish the document
document.close();
}
</script>
Post a Comment for "How Do You Stop Browser From 'hourglassing' When Javascript Is DONE (stop Throbber)?"