is there any way to change the URL in browser without reloading page after click a DOM element?
$('#filter_form').on('change', function () {
$.ajax(options);
//change the browser URL
});
Ex:
Before: http://somepage.com/filters
After: http://somepage.com/filters?type=apartment
Yes, this is possible with the history API . Both history.pushState
and history.replaceState
let you specify a new URL, eg:
history.pushState(null, null, "filters?type=apartment");
The URL is resolved in the usual way.
Browser support is good , other than IE9 and earlier.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.