views:

58

answers:

2

I have been trying to display the Loader.gif image when the form is submitted, it works fine with FF browser but doesnt work with IE, I tried with settimeout() function of javascript which helped to resolve the problem for IE but then it was not working with FF

So someone could pls provide me a detail working example for both FF and IE??

+1  A: 

If you are uploading an image, you could just have the loader.gif hidden using CSS (display: none;) and then in the forms onSubmit event put something like document.getElementById("loaderImageID").style.display = "block"; (or instead of block, whatever display type you need) which would show the image after the user has clicked the submit/upload/whatever button, and when the page refreshes the image would be gone.

(Unless I have misunderstood what you are trying to do, i do not see the need for setTimeout())

EDIT: Ok this is the updated copy of the code (which should work exactly as you need now)

<html>
    <head>
        <script type="text/javascript">
            function uploading()
            {
                //Show the placeholder div
                document.getElementById("loader").style.display = "block";

                //Create a new image element with the loader.gif as the source
                var loader = document.createElement("img")
                loader.setAttribute("src","loader.gif");
                //Add the loader image to the loader div
                document.getElementById("loader").appendChild(loader);
            }
        </script>
    </head>
    <body>
        <!-- Placeholder for the loader (style it as you wish)-->
        <div style="display: none; height: 50px; width: 50px;" id="loader"></div>
        <a href="javascript: uploading();">Test</a>
        <form onSubmit="uploading();">
            <input type="submit" onClick="uploading();"/>
        </form>
    </body>
</html>

I have used a loader from the site that you linked to and faced the same problem to start with. The problem is caused by the element being invisible when it was added to the DOM. Afterwards when you show the element IE does not start the animation. (source)

Chief17
It wont work in IE try it.. this is what i am facing the problem, I am already with the solution u have given to me....
OM The Eternity
I am talking about browser compatibility animated images do not work with this pattern of code in IE.. try it.. I am available with same solution, and i read somewhere that setTimeout() function will fix this, but i am not able to implement this..please see how can i use this
OM The Eternity
Check my edit, i have tried it in IE with an actual animated GIF and it works. If this does not solve it, perhaps you can ZIP up your files upload them somewhere and send me a link?
Chief17
+1 Yes You are right, It works with IE, but i need a progress bar which needs to be working just like urs, just download any of the "progress bar" gif image from http://ajaxload.info/ and then try it in IE it wont work..plsstry it, i am very thank ful to you for helping with such a long run.. pls dont give up with my problem chief..thanx again
OM The Eternity
Check my new edit :o)
Chief17
I am very much Thanxified Chief... :)
OM The Eternity
No probs, glad I could help :o)
Chief17
A: 

Can you give us some more information as to the functionality of this page?

nokturnal