Давно хотел поставить некий скрипт, чтобы пользователь во время загрузки странички видел не начало года, а попадал сразу на текущий день, чтобы страница сразу проматывалась к id.
Январь
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Февраль
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Март
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Апрель
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Май
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Июнь
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Июль
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Август
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Сентябрь
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Октябрь
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Ноябрь
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Декабрь
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
<script>
window.addEventListener('DOMContentLoaded', function() {
if(location.href.indexOf('#')== -1) {
var mes = document.querySelectorAll('section.mes');
mes[new Date().getMonth()].className = 'mes raz';
location.hash = "#mes"+new Date().getMonth()+new Date().getDate();
}
}, false);
</script>
<style>
.mes.raz {
outline: 1em solid #f9f9f9;
background: #f9f9f9;
}
</style>
<section class="mes">
<h4>Январь</h4>
<p><strong id="mes01">1</strong>
<p><strong id="mes02">2</strong>
<p><strong id="mes03">3</strong>
<p><strong id="mes04">4</strong>
<p><strong id="mes031">31</strong>
</section>
<section class="mes">
<h4>Февраль</h4>
<p><strong id="mes11">1</strong>
<p><strong id="mes12">2</strong>
<p><strong id="mes13">3</strong>
<p><strong id="mes14">4</strong>
<p><strong id="mes129">29</strong>
</section>
<section class="mes">
<h4>Март</h4>
</section>
<section class="mes">
<h4>Апрель</h4>
</section>
<section class="mes">
<h4>Май</h4>
</section>
<section class="mes">
<h4>Июнь</h4>
</section>
<section class="mes">
<h4>Июль</h4>
</section>
<section class="mes">
<h4>Август</h4>
</section>
<section class="mes">
<h4>Сентябрь</h4>
</section>
<section class="mes">
<h4>Октябрь</h4>
</section>
<section class="mes">
<h4>Ноябрь</h4>
</section>
<section class="mes">
<h4>Декабрь</h4>
<h4>Январь</h4>
<p><strong id="mes111">1</strong>
<p><strong id="mes112">2</strong>
<p><strong id="mes113">3</strong>
<p><strong id="mes114">4</strong>
<p><strong id="mes1131">31</strong>
</section>
4 комментария:
Спасмибо.