Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    [classe] sintassi corretta

    salve, sto cercando di creare un oggetto, ma pare che sia errata questa sintassi:

    codice:
    function EFX()
    {
    		
    	this.brow$er = function()
    	{
    		brow$ = navigator.userAgent.toLowerCase();
    
    		return
    		{
    			IE:function()	 	{return (brow$.match("msie") 	!= null);},
    			FF:function() 		{return (brow$.match("firefox") != null);},
    			SAFARI:function() 	{return (brow$.match("safari") 	!= null);},
    			OPERA:function() 	{return (brow$.match("opera") 	!= null);},
    			CHROME:function()	{return (brow$.match("chrome") 	!= null);}
    		}
    
    	}
    
    
    ........
    .....
    ....
    }
    insomma, la funzione brow$er mi deve tornare dei valori booleani in base al browser, dov'è che sbaglio?
    mi torna un errore di sintassi nel punto "IE:function()"
    Sono così maledettamente attraente...

    QuickChat. (Asp e ajax)

  2. #2
    ok, scusate, ho risolto attaccando la parentesi graffa al return.

    ora però il problema è che mi torna "undefined"
    alla chiamata.

    la chiamata la faccio così:

    var o = new EFX()

    alert(o.brow$er.IE)


    dove sbaglio stavolta?
    Sono così maledettamente attraente...

    QuickChat. (Asp e ajax)

  3. #3
    Codice PHP:
    function EFX(){
        
    this.brow$er = function()
        {
            var 
    brow$ = navigator.userAgent.toLowerCase();
            return {
                
    IE:function(){  return (brow$.match("msie") != null);},
                
    FF:function(){  return (brow$.match("firefox") != null);},
                
    SAFARI:function(){  return (brow$.match("safari")     != null);},
                
    OPERA:function(){   return (brow$.match("opera")     != null);},
                
    CHROME:function(){   return (brow$.match("chrome")     != null);}
            };
        }
    }

    var 
    = new EFX()
    alert(o.brow$er().IE()) 
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.