How to Delay an Image/HTML loading?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • http://links.i6networks.com

    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.



  • Alberto

    #2
    Re: How to Delay an Image/HTML loading?

    It depends on what you want to do.

    The first idea could be, give an id to the image and then
    function foo(){
    document.getEle mentById("image Id").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.getEle mentById("layer 1");
    var image = document.create Element("IMG"); //UPPERCASE!
    appendToId.appe ndChild(image);
    image.width=100 ;//custom
    image.height=10 0;//custom
    image.src="mygi f.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://links.i6network s.com" <SaveWorldFromA ids@alexa.com> ha scritto nel
    messaggio news:KlZTc.2000 $FZs1.294@news0 4.bloor.is.net. cable.rogers.co m...[color=blue]
    > 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.
    >
    >
    >[/color]


    Comment

    • http://links.i6networks.com

      #3
      Re: How to Delay an Image/HTML loading?

      Are you sure that onload is called after body finished loading? I thought
      onload is called when it first get loaded.
      [color=blue]
      > It depends on what you want to do.
      >
      > The first idea could be, give an id to the image and then
      > function foo(){
      > document.getEle mentById("image Id").src="mygif .gif";
      > }
      > <body onLoad="foo()">
      >
      > this changes the src of the image only after the page has loaded. But[/color]
      maybe[color=blue]
      > 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.getEle mentById("layer 1");
      > var image = document.create Element("IMG"); //UPPERCASE!
      > appendToId.appe ndChild(image);
      > image.width=100 ;//custom
      > image.height=10 0;//custom
      > image.src="mygi f.gif";//custom
      > }
      >
      > then <body onLoad="foo()">
      >
      > I hope I didn't insert any typo or silly error, writing on the run you[/color]
      see,[color=blue]
      > but they seem valid ideas
      >
      > ciao
      > Alberto
      > http://www.unitedscripters.com/
      >
      >[/color]


      Comment

      • Chris Hope

        #4
        Re: How to Delay an Image/HTML loading?

        http://links.i6networks.com wrote:
        [color=blue]
        > Are you sure that onload is called after body finished loading? I thought
        > onload is called when it first get loaded.[/color]

        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/

        Comment

        • Michael Winter

          #5
          Re: How to Delay an Image/HTML loading?

          [Follow-ups set to clj]

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

          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

          Comment

          • GreyWyvern

            #6
            Re: How to Delay an Image/HTML loading?

            On Mon, 16 Aug 2004 07:27:38 GMT, http://links.i6networks.com
            <SaveWorldFromA ids@alexa.com> wrote:
            [color=blue]
            > 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.[/color]

            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

            Comment

            Working...