Matt
Matt

Reputation: 3

Changing css dependent on domain and adding "?" into domain

First post here but I'll get on with it, I was having some trouble with finding out how to change a site's CSS dependent on the domain, what I mean by that is like if I wanted "example.com" to display a coming soon page but if you change the domain to "example.com?bypass=keyhere" then it displays the actual site that is being built, I mentioned CSS because I was thinking of changing visibility of elements, etc. but I do not even know how to get started with having it detect what the proper domain is.

Upvotes: 0

Views: 434

Answers (1)

Kiran Shinde
Kiran Shinde

Reputation: 5992

You can query params using

function urlParam(name){
   var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
   if (results == null){
      return null;
  }
  else {
     return decodeURI(results[1]) || 0;
  }
}

if (urlParam.bypass === 'keyhere') {
     // if you want to do something
} else {
     document.body.classList.add('hideContent')
}

Upvotes: 1

Related Questions