For security reasons, JavaScript will not have access to what the user types in the URL string.
But if you mean that they click a link on your page to go to a new page, you can do this:
$('a').click(function(){
var nextPage = $(this).attr('href');
});
Or if the redirection is in your JavaScript window.location.href setting, do the following:
$(window).unload(function(){
var nextPage = window.location.href;
});
source
share