I have a simple dropdown that forwards to a new url onChange.
It looks like this:
function changeCompanyType(companyType) {
window.location.href = 'type/'+companyType+'/';
}
The first change works great and goes to the url:
The next time I click on the dropdown from the new page it adds type and the company type again:
How can I just have the company type changed so the url doesn't keep being added to?
Prefix with a forward slash ( /
)
window.location.href = '/type/'+companyType+'/';
^ -- a slash to make an absolute url
// or (depends on what you want to do)
window.location.href = '/companies/type/'+companyType+'/';
^ -- a slash to make an absolute url
Add a '/'
at the front of the link like this
function changeCompanyType(companyType) {
window.location.href = '/type/'+companyType+'/';
}
Use:
function changeCompanyType(companyType) {
window.location.href = '/type/'+companyType+'/';
}
Add line:
companyType = '';
after you have set the href.
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.