Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/03/2008, 09:02
Avatar de damorcor
damorcor
 
Fecha de Ingreso: julio-2003
Ubicación: Madrid
Mensajes: 16
Antigüedad: 21 años, 6 meses
Puntos: 1
Re: Detectar si ActiveX esta habilitado

Creo que con este codigo esta solucionado
Ademas te detecta si esta habilitado las cookies, javascript y ajax.



Código HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>Comprobar compatibilidad con Ajax en el navegador</title>
<script type="text/javascript">
<!--
    // Cookie handling 
    var Cookie =
    {
        read: function (name)
        {
            var arrCookies = document.cookie.split ('; ');
            for (var i=0; i<arrCookies.length; i++)
            {
                var arrCookie = arrCookies[i].split ('=');
                
                if (arrCookie[0] == name)
                {
                    return decodeURIComponent (arrCookie[1]);
                }
            }
            return false;
        },
    
        write: function (name, value, expires, path)
        {
            if (expires)
            {
                var date = new Date ();
                date.setTime (date.getTime () + (((((expires * 24) * 60) * 60) * 1000)));
                expires = '; expires=' + date.toGMTString ();
            }
            else expires = '';
    
            if (!path) path = '/';
    
            document.cookie = name+'='+encodeURIComponent (value)+expires+'; path='+path;
        },
    
        remove: function (name)
        {
            this.write (name, '', -1);
        }
    }
    
    // Detects if can set a cookie in the browser
    function browserSupportsCookies()
    {
        Cookie.write('cookiesEnabled', 1);
        var boolCookiesEnabled = Cookie.read('cookiesEnabled');
        Cookie.remove('cookiesEnabled');
        if (boolCookiesEnabled != 1)
        {
            return false;
        }
        return true;
    }
    
    // Detects if the browser supports Ajax 
    function browserSupportsAjax()
    {
        if (typeof XMLHttpRequest == "undefined" && typeof ActiveXObject == "undefined" && window.createRequest == "undefined")
        {
            return false;
        }
        return true
    }
    
    // Detects if the browser can use ActiveX if necessary
    function ActiveXEnabledOrUnnecessary ()
    {
        if (typeof ActiveXObject != "undefined")
        {
            var xhr = null;
            try{
                xhr=new ActiveXObject("Msxml2.XMLHTTP");
            }catch (e){
                try{
                    xhr=new ActiveXObject("Microsoft.XMLHTTP");
                }catch (e2){
                    try{
                        xhr=new ActiveXObject("Msxml2.XMLHTTP.4.0");
                    }catch (e3){
                        xhr=null;
                    }
                }
            }
            if (xhr == null)
            {
                return false
            }
        }
        
        return true;
    }
-->
</script>
<!-- Detect support for cookies and Ajax and display message if not -->        
<div id="supportError">
    <noscript>
        <div>JavaScript appears to be either disabled or unsupported by your browser.
        This web application requires JavaScript to function properly.
        Please enable JavaScript in your browser settings,
        or upgrade to a browser with JavaScript support and try again.</div>
    </noscript>
    
    <script type="text/javascript">
    <!--
    
    if (!browserSupportsCookies())
    {
        var msg = '<div>Cookies appear to be either disabled or unsupported by your browser. '
        msg += 'This web application requires Cookies to function properly. ';
        msg += 'Please enable Cookies in your browser settings ';
        msg += 'or upgrade to a browser with Cookie support and try again.</div>'
        
        document.write(msg);
    }else{
		document.write("<br>Tu navegador soporta cookies");
	}
    
    if (!browserSupportsAjax())
    {
        var msg = '<div>Your browser does not appear to support Ajax technology. '
        msg += 'This web application requires Ajax to function properly. ';
        msg += 'Please upgrade to a browser with Ajax support and try again.</div>';
        
        document.write(msg);
    }else{
		document.write("<br>Tu navegador soporta Ajax");
	}
        
    if (!ActiveXEnabledOrUnnecessary())
    {
        var msg = '<div>ActiveX appears to be disabled in your browser. ';
        msg += 'This web application requires Ajax technology to function properly. ';
        msg += 'In Internet Explorer versions earlier than 7.0, Ajax is implemented using ActiveX. ';
        msg += 'Please enable ActiveX in your browser security settings ';
        msg += 'or upgrade to a browser with Ajax support and try again.</div>';
        
        document.write(msg);
    }else{
		document.write("<br>Tu navegador soporta Activex");
	}
    -->
    </script>
</div>
</head>
<body>
</body>
</html>