location.href是JavaScript中用来获取或设置当前页面URL的属性。它可以有以下几种用法:
var currentURL = location.href;
location.href = "https://www.example.com";
var url = location.href;
url += (url.indexOf('?') === -1 ? '?' : '&') + 'param=value';
location.href = url;
location.href = "https://www.example.com";
location.href = location.href;
总之,location.href属性提供了访问和修改当前页面URL的便捷方式。