Fix browser compatibility issue when accessing the window.location.origin.