-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
31 lines (27 loc) · 990 Bytes
/
Copy pathscript.js
File metadata and controls
31 lines (27 loc) · 990 Bytes
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
// Small bits of plain-DOM behavior for the landing page.
// No frameworks, no build step.
(function () {
"use strict";
// Keep the footer copyright year current.
var yearHolder = document.querySelector(".site-footer .muted:last-child");
if (yearHolder) {
yearHolder.textContent =
"© " + new Date().getFullYear() + " Trailhead. All rights reserved.";
}
// Smooth-scroll fallback for in-page anchor links (for browsers without
// CSS scroll-behavior).
var supportsSmoothScroll =
"scrollBehavior" in document.documentElement.style;
if (!supportsSmoothScroll) {
document.querySelectorAll('a[href^="#"]').forEach(function (link) {
link.addEventListener("click", function (event) {
var id = link.getAttribute("href").slice(1);
var target = id ? document.getElementById(id) : null;
if (target) {
event.preventDefault();
target.scrollIntoView({ behavior: "smooth" });
}
});
});
}
})();