为什么Safari 6和Mobile Safari(iOS 6)中的所有属性都未定义window.location

为什么Safari 6和Mobile Safari(iOS 6)中的所有属性都未定义window.location,safari,mobile-safari,Safari,Mobile Safari,我打字的时候 window.location 我在所有属性上都没有定义 这是我的控制台: 我可以确认这一点(版本6.0(8536.25))。据我所知,这似乎是一个狩猎迷 在jsbin上测试(http://jsbin.com/enugoj/1/): Safari控制台中的结果: Location ancestorOrigins: undefined hash: undefined host: undefined hostname: undefined href: undefi

我打字的时候

window.location
我在所有属性上都没有定义

这是我的控制台:

我可以确认这一点(版本6.0(8536.25))。据我所知,这似乎是一个狩猎迷

在jsbin上测试(http://jsbin.com/enugoj/1/):

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
Chrome(版本21.0.1180.89)中的结果:

此代码适用于Safari(6.0.1)及更早版本

    // Get location for REST TARGETS

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

在日志中查看时,window.location似乎“脱离上下文”。但是就地使用就可以了。

是的,这正是我得到的……所有未定义的:(Logging
JSON.parse(JSON.stringify(location));
工作正常(比如
reload
之类的方法丢失了,但你不需要检查这些方法)。问题是我需要location对象的所有属性,而不仅仅是URI。
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 
    // Get location for REST TARGETS

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