¿Supiste lo que acaba de lanzar LagriHost? Sí, como lo estabas esperando, ahora vendemos Web Hosting y Dominios. Conoce más :)


Calificación:
  • 0 voto(s) - 0 Media
  • 1
  • 2
  • 3
  • 4
  • 5
TUTORIAL Aporte: Detectar plugin instalado en el navegador web
#1
0
Que tal, les comparto una función para detectar si un plugin en especial (vía mime) está instalado o no en el navegador web, probado en firefox e internet explorer:
Código:
<html>
<head>
<script language="JavaScript">
<!--

//thanks to Código de JavaScript - Simular la función Trim() en JavaScript
function trim(str)
{

var i;

if(str != null)
{

for(i=0; i<str.length; i++)
{

if(str.charAt(i)== " ")
str = str.substring(i+1, str.length);
else
break;

}

for(i=str.length-1; i>=0; i=str.length-1)
{

if(str.charAt(i)== " ")
str = str.substring(0,i);
else
break;

}

}
else
str = "";

return str;

}

function replaceAll(str, strtofind, strtoreplace)
{

var pos, found, str1, str2;

if(trim(str) == "")
return "";
else
{

found = true;

while(found == true)
{

pos = str.indexOf(strtofind);

if(pos >= 0)
found = true;
else
found = false;

if(found == true)
{

str1 = str.substring(0, pos);
str2 = str.substring(pos + strtofind.length, str.length);
str = str1 + strtoreplace + str2;

}

}

return str;

}

}

//thank to Javascript and plug-ins
function existspluginsinstalledalready(mime)
{

var i, plugin, myarray, found = false;

if(trim(mime) == "")
return false;
else
{

for(i=0; i < navigator.mimeTypes.length; i++)
{

if(trim(mime).indexOf("/") > 0)
{

myarray = trim(mime).split("/");
mime = trim(myarray[1]);

}

try
{
plugin = trim(navigator.mimeTypes[i].type);
}
catch(e)
{
plugin = "";
}

if(trim(plugin).indexOf("/") > 0)
{

myarray = trim(plugin).split("/");
plugin = trim(myarray[1]);

}

mime = replaceAll(trim(mime).toLowerCase(), "x-", "");
mime = replaceAll(trim(mime).toLowerCase(), "-", " ");
plugin = replaceAll(trim(plugin).toLowerCase(), "x-", "");
plugin = replaceAll(trim(plugin).toLowerCase(), "-", " ");
//alert("mime=" + mime + "\nplugin=" + plugin);
if(trim(mime).toLowerCase().indexOf(trim(plugin).t oLowerCase()) >= 0 || trim(plugin).toLowerCase().indexOf(trim(mime).toLo werCase()) >= 0)
{

found = true;
break;

}

}

return found;

}

}

-->
</script>
</head>
<body>

<script language="JavaScript">

alert("plugin para archivos SWF = " + existspluginsinstalledalready("application/x-shockwave-flash"));
alert("plugin para archivos MP3 = " + existspluginsinstalledalready("audio/mpeg3"));
alert("plugin para archivos AVI = " + existspluginsinstalledalready("video/x-msvideo"));
alert("plugin para archivos 3GP = " + existspluginsinstalledalready("video/3gpp"));
alert("plugin para archivos PDF = " + existspluginsinstalledalready("application/pdf"));
alert("plugin para archivos B = " + existspluginsinstalledalready("application/xdb"));

</script>

</body>
</html>
Si te Agrado o Sirvió El Tema Dame Reputación Lengua


#2
0
estaba buscando eso, espero me sirva, según como me resulte te lo cuento Sonreir



Posibles temas similares…
Tema Autor Respuestas Vistas Último mensaje
  Plantillas web etoscano45 3 2,649 27-10-2019, 11:01 PM
Último mensaje: iparadise
  APORTE JAVA: Domine el lenguaje líder en aplicaciones cliente servidor - User Kevin Alfonso 1 2,948 04-08-2016, 10:59 PM
Último mensaje: asanbus
  Tutorial Aporte - Popunder Javascript para cualquier link de tu elección! Kevin Alfonso 1 2,660 19-06-2016, 07:29 PM
Último mensaje: Nomak
  Mi primera pagina web en PHP torgar22 6 4,460 30-11-2015, 06:19 PM
Último mensaje: piinbook
  Plantillas web ctoscano 5 4,375 25-08-2015, 07:48 AM
Último mensaje: sharwa



Usuarios navegando en este tema:
1 invitado(s)


Forum software by © MyBB Theme © Kevinex & iAndrew 2018