Replace window.location.origin with cross browser alternative