Can anyone explain this ASP script to me?

  • Vedette
  • Newbie
  • Newbie
  • Vedette
  • Posts: 7

Post 3+ Months Ago

I'm pretty sure what this script does, (preloads the images used for the current page), I just wanna make sure. And if someone could explain what the more complicated lines of code do exactly, that'd be great.


Code: [ Select ]
<script>
<!--
function newImage(arg) {
    if (document.images) {
        rslt = new Image();
        rslt.src = arg;
        return rslt;
    }
}
ImageArray = new Array;
var preloadFlag = false;
function preloadImages() {
    if (document.images) {

ImageArray[ImageArray.length++] = newImage(/* OWNER('object', 'dflt') *//*URL*/'images/main_htmlimage.jpg');        
ImageArray[ImageArray.length++] = newImage(/* OWNER('object', 'movr') *//*URL*/'images/main_htmlimageov.jpg');        

ImageArray[ImageArray.length++] = newImage(/* OWNER('object1', 'dflt') *//*URL*/'images/main_htmlimage1.jpg');        
ImageArray[ImageArray.length++] = newImage(/* OWNER('object1', 'movr') *//*URL*/'images/main_htmlimage1ov.jpg');        

ImageArray[ImageArray.length++] = newImage(/* OWNER('object2', 'dflt') *//*URL*/'images/main_htmlimage2.jpg');        
ImageArray[ImageArray.length++] = newImage(/* OWNER('object2', 'movr') *//*URL*/'images/main_htmlimage2ov.jpg');        

ImageArray[ImageArray.length++] = newImage(/* OWNER('object3', 'dflt') *//*URL*/'images/main_htmlimage3.jpg');        
ImageArray[ImageArray.length++] = newImage(/* OWNER('object3', 'movr') *//*URL*/'images/main_htmlimage3ov.jpg');        

ImageArray[ImageArray.length++] = newImage(/* OWNER('object4', 'dflt') *//*URL*/'images/main_htmlimage4.jpg');        
ImageArray[ImageArray.length++] = newImage(/* OWNER('object4', 'movr') *//*URL*/'images/main_htmlimage4ov.jpg');        

ImageArray[ImageArray.length++] = newImage(/* OWNER('object5', 'dflt') *//*URL*/'images/main_htmlimage5.jpg');        
ImageArray[ImageArray.length++] = newImage(/* OWNER('object5', 'movr') *//*URL*/'images/main_htmlimage5ov.jpg');        

ImageArray[ImageArray.length++] = newImage(/* OWNER('object6', 'dflt') *//*URL*/'images/main_htmlimage6.jpg');        
ImageArray[ImageArray.length++] = newImage(/* OWNER('object6', 'movr') *//*URL*/'images/main_htmlimage6ov.jpg');        

ImageArray[ImageArray.length++] = newImage(/* OWNER('object7', 'dflt') *//*URL*/'images/main_htmlimage7.jpg');        
ImageArray[ImageArray.length++] = newImage(/* OWNER('object7', 'movr') *//*URL*/'images/main_htmlimage7ov.jpg');        

        preloadFlag = true;
    }
}
function changeImages() {
    if (document.images && (preloadFlag == true)) {
        for (var i=0; i<changeImages.arguments.length; i+=2) {
            document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
        }
    }
}
// -->
</script>
  1. <script>
  2. <!--
  3. function newImage(arg) {
  4.     if (document.images) {
  5.         rslt = new Image();
  6.         rslt.src = arg;
  7.         return rslt;
  8.     }
  9. }
  10. ImageArray = new Array;
  11. var preloadFlag = false;
  12. function preloadImages() {
  13.     if (document.images) {
  14. ImageArray[ImageArray.length++] = newImage(/* OWNER('object', 'dflt') *//*URL*/'images/main_htmlimage.jpg');        
  15. ImageArray[ImageArray.length++] = newImage(/* OWNER('object', 'movr') *//*URL*/'images/main_htmlimageov.jpg');        
  16. ImageArray[ImageArray.length++] = newImage(/* OWNER('object1', 'dflt') *//*URL*/'images/main_htmlimage1.jpg');        
  17. ImageArray[ImageArray.length++] = newImage(/* OWNER('object1', 'movr') *//*URL*/'images/main_htmlimage1ov.jpg');        
  18. ImageArray[ImageArray.length++] = newImage(/* OWNER('object2', 'dflt') *//*URL*/'images/main_htmlimage2.jpg');        
  19. ImageArray[ImageArray.length++] = newImage(/* OWNER('object2', 'movr') *//*URL*/'images/main_htmlimage2ov.jpg');        
  20. ImageArray[ImageArray.length++] = newImage(/* OWNER('object3', 'dflt') *//*URL*/'images/main_htmlimage3.jpg');        
  21. ImageArray[ImageArray.length++] = newImage(/* OWNER('object3', 'movr') *//*URL*/'images/main_htmlimage3ov.jpg');        
  22. ImageArray[ImageArray.length++] = newImage(/* OWNER('object4', 'dflt') *//*URL*/'images/main_htmlimage4.jpg');        
  23. ImageArray[ImageArray.length++] = newImage(/* OWNER('object4', 'movr') *//*URL*/'images/main_htmlimage4ov.jpg');        
  24. ImageArray[ImageArray.length++] = newImage(/* OWNER('object5', 'dflt') *//*URL*/'images/main_htmlimage5.jpg');        
  25. ImageArray[ImageArray.length++] = newImage(/* OWNER('object5', 'movr') *//*URL*/'images/main_htmlimage5ov.jpg');        
  26. ImageArray[ImageArray.length++] = newImage(/* OWNER('object6', 'dflt') *//*URL*/'images/main_htmlimage6.jpg');        
  27. ImageArray[ImageArray.length++] = newImage(/* OWNER('object6', 'movr') *//*URL*/'images/main_htmlimage6ov.jpg');        
  28. ImageArray[ImageArray.length++] = newImage(/* OWNER('object7', 'dflt') *//*URL*/'images/main_htmlimage7.jpg');        
  29. ImageArray[ImageArray.length++] = newImage(/* OWNER('object7', 'movr') *//*URL*/'images/main_htmlimage7ov.jpg');        
  30.         preloadFlag = true;
  31.     }
  32. }
  33. function changeImages() {
  34.     if (document.images && (preloadFlag == true)) {
  35.         for (var i=0; i<changeImages.arguments.length; i+=2) {
  36.             document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
  37.         }
  38.     }
  39. }
  40. // -->
  41. </script>



thanks a lot in advance.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

This is indeed a script for preloading images, However it isn't an ASP script.
ASP (Active Server Pages) put together data where it is being fetched from then send it to the browser.

As far as I know any script that uses document.anything is a client-side script (Javascript 999/1000 times).

This function will help better explain,
Quote:
function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
}
}
}


Note "document.images", "preloadFlag", & ".src"
preloadFlag holds true or false, if true then the browser has finished with processing the preloadFunction and can now set the ".src" (source/url) of the image objects.

As for the more complicated lines, well it's a little hard to know which ones are complicated to you.
If you can point out a certain line I or someone else will surely be able to explain it for you. :D
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

And while you are at it, there is most likely a counterpart to that script which will be the javascript that actually handles the rollovers. The two work hand in hand.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: demonmaestro and 169 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.