Execute JS by URL
Posted on October 25, 2017 in JavaScript by Matt Jennings
If on “mattjennings.net/blog” URL Execute JS
var pageUrl = window.location.href;
if(pageUrl.toLocalLowerCase().indexOf('mattjennings.net/blog') != -1) {
// JS to execute here
}
If NOT on “mattjennings.net/blog” URL Execute JS
var pageUrl = window.location.href;
if(pageUrl.toLocalLowerCase().indexOf('mattjennings.net/blog') == -1) {
// JS to execute here
}