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 12 of 12
  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript countdown help

    Hi,

    I not a javascipt programer, but I do know a bit of asp and php so I can kinda get around working out what someone has done if its not too complicated.

    I downloaded a countdown script from Dithered the other day. Its an image based counter.

    It works fine with IE5 mac, mozilla and safari.

    My problem with the script is with IE6 win, what happens is that IE6 keeps downloading the images as the counter counts. This makes the counter clunky and slow. IE6 also never stops working because of it, the little windows icon that moves to indicate downloading is always moving. If you hit stop the numbers dissapear and then it all starts over.

    Strange thing is that it works fine on my local server. It also works fine on the dithered demo.

    I suspect the problem is something with the path in linking the images. Locally and on the demo relative paths were used. On my site I had to use absolute paths like so" /images/nameofimage.gif" instead of "images/nameofimage.gif" becuase the counter appears in my sidebar which appears on all my pages some of which are not in the root.

    Could anybody please take a look at it, or give some advice?
    If anyone knows of any good image based Dom based javascript countdown timers it would be much appritiated.

    You can see the timer on my site.

    Thanks

  • #2
    New Coder
    Join Date
    Jan 2004
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what you probably want to do is take all of the images that you are going to be using for the counter and pre load them into your browser that way you will not get the loading lag. and because it is changing every second you might want to make sure that the images are very small because if you are using 10 highres images it will create the load lag as well

    hope it works out

  • #3
    New Coder
    Join Date
    Jan 2004
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks josses,

    The number images themselves are tiney.
    How can I peload the images?

  • #4
    New Coder
    Join Date
    Jan 2004
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    onLoad="MM_preloadImages('logo.jpg','cw.jpg','ccw.jpg')"

    <script language="JavaScript">
    <!--
    function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    //-->
    </script>


    this is a macromedia preload image script put the script in the head of the page

    then in the onload of the body tag put the images with their location from the root folder into the function like above

    put them in '' and seperate them with a ,

    hope that works and www.wsabstract.com has a great tutorial on it as well

  • #5
    New Coder
    Join Date
    Jan 2004
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks will give it a try...

  • #6
    New Coder
    Join Date
    Jan 2004
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry, one question, how does the code look for the onload body part, I understand the images part but not sure about the syantex for onload.

  • #7
    New Coder
    Join Date
    Jan 2004
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so copy the script part into the head tag

    and in the <body> tag place

    onLoad="MM_preloadImages('image1.jpg','image2.jpg','...etc')"

    <body onLoad="MM_preloadImages('image1.jpg','image2.jpg','...etc')">

  • #8
    New Coder
    Join Date
    Jan 2004
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this is a simpler preload image script from wsabstracts.com free scripts archive

    it is pretty self explanitory

    <script>

    /*
    Preload images script
    By JavaScript Kit (http://javascriptkit.com)
    Over 400+ free scripts here!
    */

    var myimages=new Array()
    function preloadimages(){
    for (i=0;i<preloadimages.arguments.length;i++){
    myimages[i]=new Image()
    myimages[i].src=preloadimages.arguments[i]
    }
    }


    //Enter path of images to be preloaded inside parenthesis. Extend list as desired.
    preloadimages("http://mydomain.com/firstimage.gif","http://mydomain.com/secondimage.gif","http://mydomain.com/thirdimage.gif")

    </script>

    you don't have to put the complete virtual image file path in
    eg:
    preloadimages("1.gif","2.gif","3.gif")
    you can put all your Number image names in here

  • #9
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you want to do a fantastically easy job, you could utilize Pixy's CSS Rollover method to change everything. Then you'd only have to wait for one image to load. Of course you'd have to rewrite the script from scratch, but... hey, a new project for me. Woo-hoo!

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.

  • #10
    New Coder
    Join Date
    Jan 2004
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the help guys, gonna give that second script a try and see if it works...

  • #11
    New Coder
    Join Date
    Jan 2004
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Found this preloader on the dithered site, I suppose I'll try this first because all the scripts there are supposed to be cross browser compatible.

    function preloadImages() {
    document.preload = new Array();
    if (document.images) {
    for (var i = 0; i < preloadImages.arguments.length; i++) {
    document.preload[i] = new Image();
    document.preload[i].src = preloadImages.arguments[i];
    }
    }
    }

  • #12
    New Coder
    Join Date
    Jan 2004
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    being trying them out and I seem to be havig a problem with my blog management system Movabletype. Its wont save the template passed the preload function call on any of the above scripts.

    Ps does anybody know how to append to the onload call in the body tag.


  •  

    Posting Permissions

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