Use window.location.href rather than window.location