Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var main = document.querySelector('main');
- function showPage(name) {
- var html = document.getElementById(`t-${name}`).innerHTML;
- main.innerHTML = html;
- }
- window.addEventListener('hashchange', function() {
- setPageFromHash();
- });
- function setPageFromHash() {
- var hash = window.location.hash.substr(1);
- if (hash === 'about') {
- showPage('about');
- } else {
- showPage('home');
- }
- }
- setPageFromHash();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement