Skip to content

Instantly share code, notes, and snippets.

@dribble13
Last active December 26, 2015 04:58
Show Gist options
  • Select an option

  • Save dribble13/7096913 to your computer and use it in GitHub Desktop.

Select an option

Save dribble13/7096913 to your computer and use it in GitHub Desktop.
ブラウザ側で日時指定で、リダイレクト先を切り替えるスクリプト ref: http://qiita.com/dribble13/items/cd5aa40d87d1e993bb51
$(document).ready(function() {
$('a.location_timer').each(function(index, target) {
var startDate = $(this).attr('data-start-date');
var endDate = $(this).attr('data-end-date');
var nowDate = new Date();
startDate = startDate ? new Date(startDate) : nowDate;
endDate = endDate ? new Date(endDate) : null;
if (startDate <= nowDate && (!endDate || nowDate <= endDate)) {
location.href = $(this).attr('href');
}
});
});
<a class="location_timer" href="http://qiita.com" data-start-date="2013/10/22 16:00" data-end-date="2013/10/30 23:59"></a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment