I want to check Prod, dev and QA URL based on the URL i need to refer a .js file
Production URL: domain.com and www.domain.com
i should refer: src=prod.js file if the URL is production url
Dev and QA URLs: dev.domain.com and staging.com
i should refer: src= staging.js file if the URL is dev or QA or both,
I wish to use this window.location.href.search using if else condition.
Please help me with the if else condition using javascript.
I tried the with the below code but it is not working
if (window.location.href.search("domaing.com")!=-1 && window.location.href.search("staging.vicodin.com"|"dev.domain.com)==-1) {
src=prod.js
}
else{
src=staging.js
}
Please help me to have the correct code
You have several problems with your condition:
"
after dev.domain.com)Here is a correct solution: