2012-06-25 4 views

risposta

4

posso confermare questo (Versione 6.0 (8.536,25)). Sembra essere un bug di Safari, per quanto posso dire.

Testato su jsbin (http://jsbin.com/enugoj/1/):

console.log(window.location); 
console.log(window.location.pathname);​ 

Risultati in console di Safari:

Location 
    ancestorOrigins: undefined 
    hash: undefined 
    host: undefined 
    hostname: undefined 
    href: undefined 
    origin: undefined 
    pathname: undefined 
    port: undefined 
    protocol: undefined 
    search: undefined 
    __proto__: LocationPrototype 

/enugoj/1 

Risultati in Chrome (versione 21.0.1180.89) :

Location 
    ancestorOrigins: DOMStringList 
    assign: function() { [native code] } 
    hash: "" 
    host: "jsbin.com" 
    hostname: "jsbin.com" 
    href: "http://jsbin.com/enugoj/1" 
    origin: "http://jsbin.com" 
    pathname: "/enugoj/1" 
    port: "" 
    protocol: "http:" 
    reload: function() { [native code] } 
    replace: function() { [native code] } 
    search: "" 
    toString: function toString() { [native code] } 
    valueOf: function valueOf() { [native code] } 
    __proto__: Location 
    1:14 

/enugoj/1 
+1

Sì, è esattamente quello che ottengo ... tutto indefinito :( –

5

Questo codice funziona in Safari (6.0.1) e precedenti

Sembra che window.location "esca dal contesto" quando si guarda nel registro. Ma sul posto usato va bene.

+0

Il fatto è che mi aspetto tutte le proprietà dell'oggetto posizione, non solo l'URI. –