1 Open this page in Safari 4.

2 Open the debugging Error Console (cmd-opt-C)

3 Notice that win_loc.href: string, loc.href: string, location.href: string, window.location.href: string is getting printed to the console. This is expected.

4 Navigate to a page on a different domain, like Google or GitHub.

5 Press the back button.

6 Notice that win_loc.href: undefined, loc.href: undefined, location.href: string, window.location.href: string is getting printed to the console. What's up with those undefined, Safari?

Tested in Safari Version 4.0.4 (5531.21.10) / WebKit nightly r54415. Submitted to WebKit Bugzilla as Bug 34679.

The code

(function(window){
  
  // A convenient shortcut.
  var win_loc = window.location,
    loc = location,
    state;
  
  (function loopy(){
    console.log([
      'win_loc.href: ' + typeof win_loc.href,
      'loc.href: ' + typeof loc.href,
      'location.href: ' + typeof location.href,
      'window.location.href: ' + typeof window.location.href
    ].join(', '));
    timeout_id = setTimeout( loopy, 1000 );
  })();
  
})(this);