47 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<div class="back">🡄</div>
 | 
						|
<button onclick="topFunction()" id="topBtn" title="Go to top">🡅</button>
 | 
						|
 | 
						|
<script>
 | 
						|
let topButton = document.getElementById("topBtn");
 | 
						|
 | 
						|
window.onscroll = function() {scrollFunction()};
 | 
						|
 | 
						|
function scrollFunction() {
 | 
						|
  if (document.body.scrollTop > 80 || document.documentElement.scrollTop > 80) {
 | 
						|
    topButton.style.display = "block";
 | 
						|
  } else {
 | 
						|
    topButton.style.display = "none";
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
function topFunction() {
 | 
						|
  document.body.scrollTop = 0;
 | 
						|
  document.documentElement.scrollTop = 0;
 | 
						|
}
 | 
						|
 | 
						|
var back = document.querySelector(".back");
 | 
						|
 | 
						|
window.addEventListener('pageshow', (event) => {
 | 
						|
	event.preventDefault();
 | 
						|
	if(window.location.hash != ""){
 | 
						|
		console.log('#');
 | 
						|
		setTimeout(function(){
 | 
						|
			var id = window.location.href.split("#")[1];
 | 
						|
			document.getElementById(id).scrollIntoView({behavior: "smooth", block: "start", inline: "nearest"});
 | 
						|
		},100);
 | 
						|
	}
 | 
						|
}, false);
 | 
						|
 | 
						|
if(window.location.pathname.split('/').pop() != "index.html"){
 | 
						|
	back.style.display = "block";
 | 
						|
	back.addEventListener("click", function(){
 | 
						|
		if(window.history.length >=2){
 | 
						|
			window.history.back();
 | 
						|
			//window.history.go(-1);
 | 
						|
		}else{
 | 
						|
			window.location.href = "../../index.html";
 | 
						|
		};
 | 
						|
	});
 | 
						|
};
 | 
						|
</script>
 |