SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: edit script

Hybrid View

  1. #1
    SitePoint Wizard geiger's Avatar
    Join Date
    Jul 2001
    Posts
    2,459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    edit script

    hey guys. i have a script which shows a bar for the progress of images loaded. i need to edit it, but i'm not very good in javascript. i need anything about being transfered to another page taken out. also, once the images are loaded, the bar needs to stay there, and it will become an 11x60 color #666699 when everything is loaded. can someone help please?

    in head:
    PHP Code:
    <script language="JavaScript1.1">var locationAfterPreload "#" // URL of the page after preload finishes
    var lengthOfPreloadBar 60
    var heightOfPreloadBar 11
    // Put the URLs of images that you want to preload below (as many as you want)
    var yourImages = new Array("/home.gif","/about.gif","/design.gif","/portfolio.gif","/contact.gif","/bg.gif","/fullbg.gif","/violetbg.jpg")
    // Do not modify anything beyond this point!
    if (document.images) {
    var 
    dots = new Array() 
    dots[0] = new Image(1,1)
    dots[0].src "/bar.gif" // default preloadbar color (note: You can substitute it with your image, but it has to be 1x1 size)
    dots[1] = new Image(1,1)
    dots[1].src "/violetpixel.gif" // color of bar as preloading progresses (same note as above)
    var preImages = new Array(),coverage Math.floor(lengthOfPreloadBar/yourImages.length),currCount 0
    var loaded = new Array(),i,covered,timerID
    var leftOverWidth lengthOfPreloadBar%coverage
    }
    function 
    loadImages() { 
    for (
    0yourImages.lengthi++) { 
        
    preImages[i] = new Image()
        
    preImages[i].src yourImages[i]
    }
    for (
    0preImages.lengthi++) { 
        
    loaded[i] = false
    }
    checkLoad()
    }
    function 
    checkLoad() {
    if (
    currCount == preImages.length) { 
        
    location.replace(locationAfterPreload)
        return
    }
    for (
    0<= preImages.lengthi++) {
        if (
    loaded[i] == false && preImages[i].complete) {
            
    loaded[i] = true
            
    eval("document.img" currCount ".src=dots[1].src")
            
    currCount++    }
    }
    timerID setTimeout("checkLoad()",10
    }
    // end hiding -->
    </script> 
    in body:
    PHP Code:
    <script language="javascript1.1">
    <!-- 
    begin hiding
    if (document.images) {
    var 
    preloadBar ''
    for (0yourImages.length-1i++) {
        
    preloadBar += '<img src="' dots[0].src '" width="' coverage '" height="' heightOfPreloadBar '" name="img' '" align="absmiddle">'
    }
    preloadBar += '<img src="' dots[0].src '" width="' + (leftOverWidth+coverage) + '" height="' heightOfPreloadBar '" name="img' + (yourImages.length-1) + '" align="absmiddle">'
    document.write(preloadBar)
    loadImages()
    }
    // end hiding -->
    </script> 
    thanks

  2. #2
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    geiger...would you mind taking out the <PHP> designation please? It causes the page to break.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes


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
  •