Custom-JavaScript-for-Websites-2
Custom-JavaScript-for-Websites-2 copied to clipboard
URL change
I run a script on domain.com. I have specified in my script that it should only run on domain.com/subdomain1. However, when I navigate back and forther between domain.com and domain.com/subdomain1 or domain.com/subdomain2 the script keeps running.
I am no expert in JS and frankly lost. Any help would be appreciate!
Thanks for the great work anyway.
Jonathan
There is existing issue for this #5
But unfortunately, there are some difficulties to implement such functionality and need to redesign the entire logic for injecting scripts.
There is a workaround to handling such cases: write a function to check whether the domain is the desired domain you need, like:
function domainMatched() {
return window.location.href.contains("domain.com/subdomain1"))
}