Function that return the previous page visited for the user.
pathArray = document.referrer.split( '/' );
protocol = pathArray[0];
host = pathArray[2];
url_anterior = protocol + '//' + host;
url_actual = window.location.protocol + "//" + window.location.host;
function goBackOrGoHome(){
if ( url_anterior == url_actual) {
window.history.back();
}else{
window.location = home_url;
};
}