If I'm, for example, on this page
www.example.com/admin/bridge/boilerplate
What is the best way (Using plain javascript, or jQuery (Without loading another plugin) to go up one level, e.g.
www.example.com/admin/bridge
At the moment we are using
window.history.go(-1);
which interferes with submitted forms, etc. This is used normally on a function like this:
$("button.cancel").bind("click", function( e ){
window.history.go(-1);
e.preventDefault();
});
Simple:
var url = window.location.href;
if (url.substr(-1) == '/') url = url.substr(0, url.length - 2);
url = url.split('/');
url.pop();
window.location = url.join('/');
var i = window.location.href.lastIndexOf("/");
window.location = window.location.href.substr(0,i)
thanks, but this edited:
$("#back a").click(function() {
var url = window.location.href;
if (url.substr(-1) == '/') url = url.substr(0, url.length - 2);
url = url.split('/');
url.pop();
window.location = url.join('/');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With