473,508 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Delay an Image/HTML loading?

I need to delay something either an image or a table from loading for 2-5
seconds. So far I have not find a good method.

I need the rest of the page, even the codes after the delayed image, to be
displayed in real time.

Jul 23 '05 #1
5 7565
It depends on what you want to do.

The first idea could be, give an id to the image and then
function foo(){
document.getElementById("imageId").src="mygif.gif" ;
}
<body onLoad="foo()">

this changes the src of the image only after the page has loaded. But maybe
you mean you don't even eant the image tag till then... If so:

you can create a layer where the image is hosted and create an image node
within it after the page has loaded

DO give an id to the layer meant to host the image, say:

<div id="layer1"></div>

Now:

function foo(){
var appendToId = document.getElementById("layer1");
var image = document.createElement("IMG"); //UPPERCASE!
appendToId.appendChild(image);
image.width=100;//custom
image.height=100;//custom
image.src="mygif.gif";//custom
}

then <body onLoad="foo()">

I hope I didn't insert any typo or silly error, writing on the run you see,
but they seem valid ideas

ciao
Alberto
http://www.unitedscripters.com/

"http://links.i6networks.com" <Sa***************@alexa.com> ha scritto nel
messaggio news:Kl*****************@news04.bloor.is.net.cable .rogers.com...
I need to delay something either an image or a table from loading for 2-5
seconds. So far I have not find a good method.

I need the rest of the page, even the codes after the delayed image, to be
displayed in real time.

Jul 23 '05 #2
Are you sure that onload is called after body finished loading? I thought
onload is called when it first get loaded.
It depends on what you want to do.

The first idea could be, give an id to the image and then
function foo(){
document.getElementById("imageId").src="mygif.gif" ;
}
<body onLoad="foo()">

this changes the src of the image only after the page has loaded. But maybe you mean you don't even eant the image tag till then... If so:

you can create a layer where the image is hosted and create an image node
within it after the page has loaded

DO give an id to the layer meant to host the image, say:

<div id="layer1"></div>

Now:

function foo(){
var appendToId = document.getElementById("layer1");
var image = document.createElement("IMG"); //UPPERCASE!
appendToId.appendChild(image);
image.width=100;//custom
image.height=100;//custom
image.src="mygif.gif";//custom
}

then <body onLoad="foo()">

I hope I didn't insert any typo or silly error, writing on the run you see, but they seem valid ideas

ciao
Alberto
http://www.unitedscripters.com/

Jul 23 '05 #3
http://links.i6networks.com wrote:
Are you sure that onload is called after body finished loading? I thought
onload is called when it first get loaded.


onload is only supposed to be triggered after everything in the page has
loaded including all images, css, js files etc.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 23 '05 #4
[Follow-ups set to clj]

On Mon, 16 Aug 2004 10:52:20 GMT, http://links.i6networks.com
<Sa***************@alexa.com> wrote:
Are you sure that onload is called after body finished loading? I thought
onload is called when it first get loaded.


From the DOM 2 Events Specification:

load
The load event occurs when the DOM implementation finishes loading
all content within a document, all frames within a FRAMESET, or an
OBJECT element.

[snipped top-post]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail
Jul 23 '05 #5
On Mon, 16 Aug 2004 07:27:38 GMT, http://links.i6networks.com
<Sa***************@alexa.com> wrote:
I need to delay something either an image or a table from loading for 2-5
seconds. So far I have not find a good method.

I need the rest of the page, even the codes after the delayed image, to
be displayed in real time.


Easy[1], with PHP's sleep() command. Want to delay a table? Write a
PHP-parsed javascript file with document.write()s writing the table, then
put a sleep(5); command in the middle of it.

Same thing with images. Write a PHP image serving script, then put a
sleep(5); command before sending the output to the browser.

Grey

[1] Assuming you have a basic grasp of PHP. I'm not writing the script
for you, sorry.

--
The technical axiom that nothing is impossible sinisterly implies the
pitfall corollory that nothing is ridiculous.
- http://www.greywyvern.com - Orca Knowledgebase: Completely CSS styleable
Knowledgebase/FAQ system
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2356
by: Mekon | last post by:
I have never written a line of script in my life but I need some help with it now. I have this auto generated code which I want to modify if possible The script generates a strip of...
2
4420
by: Rob Manger | last post by:
Hi All, I am hoping someone can help me. I am trying to setup my main page so that when the user moves the mouse over an image, it changes the source (got this working). When the user CLICKS...
10
1854
by: cosmic foo | last post by:
I have a page with about 100 images of about 10k each. where a typical img tag looks like this, <img src="item001.jpg" height="70" alt="" onMouseOver="showPic(this)" border="0"> Not all the...
4
44039
by: zborisau | last post by:
Hey good people, I've been given a problem to solve recently - and stuck with the solution for a good 4 days already. i have a link which leads to popup window. the purpose of that popup...
7
3413
by: JellyON | last post by:
Hi. Is there a way to delay a call to a page counter (ie. call to a server script from an IMG tag) for the purpose to not lock the page loading awaiting counter be displayed. Maybe a...
23
5874
by: Peter | last post by:
I have a problem with a page show_image.asp that returns a jpg image under Windows XP Pro SP2. The page sets content type as: Response.ContentType = "image/jpg" While this works perfectly fine...
1
1316
by: whitesmith | last post by:
I've read the FAQ about means of implementing a delay, but nothing seems to work for me. My HTML page looks like this: <html> <head> .... usual html stuff and then: <script...
3
2721
Raventara
by: Raventara | last post by:
Hi all, I have a program which will routinely update the image of a picturebox and resize the picturebox to keep the aspect ratio of the image in tact. The problem I am having is that after about...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7401
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7063
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3211
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.