There comes a time where you will want to get a value out of the URL. Its a very easy process, just use the function below.

function getParameterByName( name ) {
name = name.replace( /[\[]/, "\\\[" ).replace( /[\]]/, "\\\]" );
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if ( results == null ) {
return "";
} else {
return decodeURIComponent( results[ 1 ].replace( /\+/g, " " ) );
}
};

The name value is the parameter from the URL that you want. For example in the following URL: http://www.awesomesite.com?userId=’1234′ if you wanted the value for userId you just pass ‘userId’ as the parameter to this method.

On your website you are looking for a way to notify your user that they are about to navigate away from your site and that any information that has not been saved will be lost.

The solution is really simple. Just listen for the ‘onbeforeunload’ event.

My example here is using jQuery.

$( window ).bind( "beforeunload", function () {
return 'All unsaved data will be lost.'
} );

Confirm Navigation