Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy text while loading image problems

    howdy!

    well its been a while since i used Javascript. i guess my problem will be a simple one for u guys/gals.

    I have one Div and in that div i have kept a img tag. i change the src property of the tag depending on where the user clicks.
    now i noticed on slower connections the image doesnt update itself as fast..
    therefore i need a "loading please wait" sign while the new src image is loading.
    how do i go about doing that?

    cause while the new image is loaded the old image is still displayed! and that i dont want!..

    please help!

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Some browsers support image onload
    Code:
    var img1 = new Image();
    img1.src = 'test.jpg';
    img1.onload = function()
    {
    alert('img1 has loaded');
    }
    What you could do is in your function that changes the picture, have a some text shown by changing a div display from none to block. Then onload of the new image change its display from block to none.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by _Aerospace_Eng_ View Post
    Some browsers support image onload
    Code:
    var img1 = new Image();
    img1.src = 'test.jpg';
    img1.onload = function()
    {
    alert('img1 has loaded');
    }
    What you could do is in your function that changes the picture, have a some text shown by changing a div display from none to block. Then onload of the new image change its display from block to none.
    hey thanks man! used the onload property but with a different way! .. thanks a ton! cheers!.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •