Help understanding code

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Help understanding code

Post by nigma »

Hey, could someone help me to understand the code that follows.

Code: Select all

<SCRIPT  LANGUAGE="JavaScript">

<!-- Hide from old browsers
&#123;  // This doesn't seem normal? They have a &#123; without a function or
    // some other type of loop before it.
  var Position = 0;
  var    tid =   "";
&#125;

function ImgLoaded()
&#123;  alles = true;  // Here, they do it again.
&#123;  for (j=0; j < document.images.length; j++)  
	&#123;alles = alles && document.images&#1111;j].complete;
	&#125;
&#125; 
return alles;
&#125;

function Slideit()
&#123;//alert(navigator.appVersion)
  if ((document.layers) || (document.all))&#123;
  Position = Position + 5;
  window.status = ' connect ' + Position + ' baud to tranquileye.com ';
  tid = setTimeout("Slideit()",9);
  if (Position<1400) 
     &#123;scroll(0,Position);&#125;
  else &#123;scroll(0,Position+00);&#125;
  if ((Position>2400)&& ImgLoaded())
	&#123; clearTimeout(tid);
  if (document.layers || document.all)&#123;
         document.location="home.html"
     &#125;
  &#125;
&#125;
  else
     &#123;parent.location='home.html'&#125; // go to version 3 window

&#125;
// Stop hiding from old browsers -->
</SCRIPT>
<SCRIPT language="JavaScript">
<!--
function MM_preloadImages() &#123; //v1.2
  if (document.images) &#123;
    var imgFiles = MM_preloadImages.arguments;
    var preloadArray = new Array();
    for (var i=0; i<imgFiles.length; i++) &#123;
      preloadArray&#1111;i] = new Image;
      preloadArray&#1111;i].src = imgFiles&#1111;i];
    &#125;
  &#125;
&#125;
//-->
</SCRIPT>
<SCRIPT language="JavaScript">
<!--
function MM_popupMsg(theMsg) &#123; //v1.2
  alert(theMsg);
&#125;
//-->
</SCRIPT>
Now, my I did little C++ style comments where I had questions. I only commented the main things I did not understand, but I really understood little. So any explanations are great. Basically I found this code on a page that is so awesome that I wanted to know how to do that, well I didn't understand hardly anything in it.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Dreamweaver automated code for pre-caching and sliding images. Never search for style in the code of an editor. :P The curly brackets are mostly redundant.
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

Indeed, if it works.... Don't try to understand it.

If it doesn't work, rebuild it.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

So intern, you are telling me if it works, then forget about learning about it, and just use it? And if it doesn't, rebuild code I do not even understand?
Post Reply