Image

Imageex_lifeofbri692 wrote in Imagejavascript 😊content

sometimes i appreciate javascript and DOM

For a project at work I have a webpage that generates png images on the fly with line charts and scatter plots. Each image takes about 8seconds to generate (grabs mysql data, parses it in php, and creates the image using the GD libraries). The problem is that the user has no idea about what the thing is doing (unless they're smart and realize it takes awhile to load stuff).

So I placed an onLoad='cacheOff()' in the body tag and I utilized the following script:

<script language="JavaScript">
    ver = navigator.appVersion.substring(0,1)
    if (ver >= 4) {
        document.write('<DIV ID="cache"><img src="/img/loadingmetrics.gif"></DIV>');
        var cache = document.all.cache.style;
        largeur = screen.width;
        cache.left = Math.round(100);
        cache.visibility = "visible";
    }
    function cacheOff()
    {
        if (ver >= 4)
                {
                cache.visibility = "hidden";
                }
    }
    </script>