Use document.URL in place of window.location.href for refresh.