Current location: Hot Scripts Forums » General Web Coding » JavaScript » Loading Image


Loading Image

Reply
  #1 (permalink)  
Old 02-15-05, 12:32 PM
Rodi Rodi is offline
New Member
 
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Question Loading Image

hi guys,

I want to show a loading gif animated before loading the actual image. So, if the actual image to load is too big, the user will see the gif animation before.

Thanks
Reply With Quote
  #2 (permalink)  
Old 02-19-05, 07:36 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
I think you can use the onload even for the <img> tag for this.
Try somehting like this:
Code:
<body>
<img id='loadergif' src="loading.gif">
<img src="big_image.jpg" onload="document.getElementById('loadergif').style.display='none';this.style.visibility='visible';" style="visibility:hidden;">
This will make the big image invisible (but it will still occupy the same physical space on your site) until it has been loaded. It will also make the gif image dissapear using style.display. The difference between visibility and display is that display doesn't make the image occupy the same space while being invisible. The reason to why I use visibility on the big image is that my reference manual says display "does not render the image". Therefor I feared that initializing the big image with display set to none, the image won't be loaded, and thus the onload event will never fire. Try it if you'd like...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
searching image nurqeen PHP 4 07-09-05 09:35 AM
Help with image on form... Adrianaa03 JavaScript 1 10-06-04 07:38 AM
how to draw an image inside a table? davidklonski HTML/XHTML/XML 2 07-06-04 10:27 AM
need help with upload image and getting image name to db mikewooten PHP 3 05-14-04 04:52 PM
Loading an image into database with customerID pecobrown PHP 2 02-27-04 01:11 PM


All times are GMT -5. The time now is 10:42 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.