有什么方法可以在单击DOM元素后更改浏览器中的URL而无需重新加载页面?
$('#filter_form').on('change', function () {
$.ajax(options);
//change the browser URL
});
前任:
前: http://somepage.com/filters
后: http://somepage.com/filters?type=apartment
是的,历史记录API可以实现。两者history.pushState
并history.replaceState
让您指定一个新的URL,例如:
history.pushState(null, null, "filters?type=apartment");
该URL以通常的方式解析。
除了IE9和更早版本之外,浏览器支持都很好。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句