如何做window.location.href法官?
如果window.location.href不匹配?search=,则使当前url跳转到http://localhost/search?search=car
我的代码不起作用,还是我应该indexOf用来做判断?谢谢。
if(!window.location.href.match('?search='){
window.location.href = 'http://localhost/search?search=car';
}