2012-06-25 38 views

Respuesta

4

puedo confirmar esto (Versión 6.0 (8.536,25)). Parece ser un error de Safari, por lo que yo sé.

Probado en jsbin (http://jsbin.com/enugoj/1/):

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

Los resultados en la consola de 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 

Resultados en Chrome (versión 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í, eso es exactamente lo que obtengo ... todo indefinido :( –

5

Este código funciona en Safari (6.0.1) y anteriores

// Get location for REST TARGETS 

    lcnURI = window.location.protocol + "//" + window.location.hostname + ":" 
      + window.location.port + "/rest/"; 

Parece que window.location "sale de contexto" cuando se mira en el registro. Pero en el lugar utilizado, está bien.

+0

El caso es que estoy esperando todas las propiedades del objeto de ubicación, no solo el URI. –

Cuestiones relacionadas