It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Explain Code

Explain Code

Postby vinith98 on Tue Feb 03, 2009 4:19 pm

Hello ppl,


Could anybody please explain me the following Javascript code, it is used to reveal passwords that is in asterisk.

Code: Select all
javascript:(function(){var s,F,j,f,i; s = ""; F = document.forms; for(j=0; j<F.length; ++j) { f = F[j]; for (i=0; i<f.length; ++i) { if (f[i].type.toLowerCase() == "password") s += f[i].value + "\n"; } } if (s) alert("Password is:\n\n" + s); else alert("No passwords");})();
vinith98
 
Posts: 3
Joined: Tue Feb 03, 2009 4:12 pm

Re: Explain Code

Postby rangana on Wed Feb 04, 2009 5:36 am

Code formatted and comments attached inline:
Code: Select all
(function(){
   var s,F,j,f,i; s = ""; // Initialize variables
   F = document.forms; // Get all the forms within the document
   for(j=0; j<F.length; ++j) { // Loop through all the forms
      f = F[j]; // Get all instance of form and save it to "f" variable
      
      for (i=0; i<f.length; ++i) { // Loop through all the form's elements
         if (f[i].type.toLowerCase() == "password") // Check if the element is of type password
            s += f[i].value + "\n"; // Append the password's value to "s" variable with a new line at the end.
         }
      }
   
   if (s) // If there's a content
      alert("Password is:\n\n" + s); // Alert the password
   else // Otherwise
      alert("No passwords"); // No password
})();
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Re: Explain Code

Postby vinith98 on Wed Feb 04, 2009 5:39 am

Thanks a lot for replying rangana
vinith98
 
Posts: 3
Joined: Tue Feb 03, 2009 4:12 pm


Who is online

Users browsing this forum: No registered users and 2 guests