Skip to main content
All CollectionsTweaks&Hacks
Make your page available for specific time frame
Make your page available for specific time frame
Aleks avatar
Written by Aleks
Updated over 6 years ago

Do you want to make your page visible only for specific time frame? It's absolutely possible to set up with DragDropr!

Just add the following script to Page Settings -> Add Scripts -> Head":

<script>
(function() {
var date = new Date(),
   hours = date.getUTCHours(),
   redirect = true,
   redirectUrl = 'http://bbc.co.uk';

if (hours < 9 || hours > 21) {
if (redirect) {
window.location.href = redirectUrl;
} else {
document.body.innerHTML = '';
}
}
})();
</script>

Depending on your needs you can do the following:

  • change the redirect = true  to redirect = false - this will cancel your page redirecting to another URL. It will show blank white page instead.

  • leave the redirect = true and change the redirectUrl = 'https://bbc.co.uk'  for example to redirectUrl = 'https://google.com' or any page you wish so that the users are redirected to it when they enter the page outside of the allowed time frame.

  • change the 9  and 21  to any other value you wish to restrict the page but remember that it uses the UTC time in comparison (GMT+0 -> https://www.timeanddate.com/worldclock/timezone/utc) so if your local time zone is GMT+3 which means that your local time is 3 hours ahead of UTC time then you would need to change the 9  to 12  and 21  to 0, etc.

That's it!

Let us know should any questions arise!

Did this answer your question?