Click to See Complete Forum and Search --> : simple question!
sujeong95
01-29-2003, 11:34 PM
I just started teaching myself javascript and I'm already stuck.
Can anybody help me out with this code?
hasFlash=false
for (i=0; i<navigator.plugins.length; i++){
if(navigator.plugins[i].name.indexOf("Flash") >=0){
hasFlash=true
}
}
If anybody could explain line by line what it does, I would greatly appreciate.
khalidali63
01-30-2003, 12:11 AM
1.hasFlash = false;
you are setting a variable to a boolean value false.this is done when in a statement where you want to determine that if some thing exists or not
2.for (i=0; i<navigator.plugins.length; i++){
you are running a for loop
The starting index for this loop is i=0
ending limit for this loop is the length of an array (pluggins object) navigator.pluggind.length;
increment order is add 1 to the existing index and then set it to the bas index.
3. if(navigator.plugins[i].name.indexOf("Flash") >=0){
you have a consition that checks pluggins array for a name property,for that name it checks that if the name has string " Flash",
If it does contain flash then goes inside the if statement and sets the variable hasFlash=true;
which means that this browser has flash installed therefore you will be able to play flash movies..
..pheeew
cheers
Khalid