入力すると
window.location
すべてのプロパティで未定義になります。
これが私のコンソールです:
このコードは Safari (6.0.1) 以前で動作します
// Get location for REST TARGETS
lcnURI = window.location.protocol + "//" + window.location.hostname + ":"
+ window.location.port + "/rest/";
ログを見ると、window.location が「文脈から外れている」ように見えます。しかし、その場で使用しても問題ありません。
これを確認できます (バージョン 6.0 (8536.25))。私が知る限り、Safariのバグのようです。
jsbin でテスト済み (http://jsbin.com/enugoj/1/):
console.log(window.location);
console.log(window.location.pathname);
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):
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