Results 1 to 4 of 4

Thread: Timer for image display.

  1. #1
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Timer for image display.

    Hello,

    Does anyone have a script that removes a picture after a certain time? I guess this would be considered a timer action script.

    Thanks

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    "remove" is not very clear in this case. I don't know of any scripts in particular that exist for this, but it would certainly be possible to make one, depending on what you mean specifically.

    Do you want to use Javascript? You just want to hide an image if it is past a certain time? You could look into scripts that display images at certain times and modify them to instead hide images (for example, element.style.display = 'none';).
    If you do use this method, though, it will be possible to find the image in the source code. Javascript can't do anything about that because it only changes what has already loaded.

    If you want to completely "remove" an image from your page so that no one can find it at all, you will need to use a serverside language like PHP-- but instead of "removing" it you just won't generate it in the first place.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    </head>
    
    <body>
    <img id="tst1" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" />
    <img id="tst2" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg" />
    
    <script type="text/javascript">
    /*<![CDATA[*/
    
    function Remove(id,ms){
     var obj=document.getElementById(id);
     if (obj&&typeof(ms)=='number'){
      setTimeout(function(){ obj.parentNode.removeChild(obj); },ms);
     }
    }
    
    Remove('tst1',4000)
    Remove('tst2',3000)
    /*]]>*/
    </script>
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    That script uses a delay (for example, 10 seconds) to remove an image. My suggestions were about absolute time (time of day, or date).

    Rydorien, which of these did you want?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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