|
|
(2 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) |
Linha 1: |
Linha 1: |
| /* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */ | | /* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */ |
| // Adiciona função para voltar ao topo
| | importStylesheetURI('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css'); |
| // Adiciona função para voltar ao topo
| |
| function addScrollToTopButton() {
| |
| // Cria o botão
| |
| var button = document.createElement('span');
| |
| button.id = 'scrollToTopButton';
| |
| button.textContent = '↑';
| |
| button.style.display = 'inline-block';
| |
| button.style.width = '30px';
| |
| button.style.height = '30px';
| |
| button.style.backgroundColor = '#007BFF';
| |
| button.style.color = 'white';
| |
| button.style.fontSize = '20px';
| |
| button.style.borderRadius = '50%';
| |
| button.style.cursor = 'pointer';
| |
| button.style.textAlign = 'center';
| |
| button.style.lineHeight = '30px';
| |
| button.style.boxShadow = '0 2px 4px rgba(0, 0, 0, 0.2)';
| |
| button.style.position = 'fixed';
| |
| button.style.bottom = '20px';
| |
| button.style.right = '20px';
| |
| button.style.zIndex = '1000';
| |
| | |
| // Adiciona o evento de clique
| |
| button.onclick = function () {
| |
| window.scrollTo(0, 0);
| |
| };
| |
| | |
| // Adiciona o botão ao corpo da página
| |
| document.body.appendChild(button);
| |
| }
| |
| | |
| // Executa a função quando a página é carregada | |
| if (typeof document.addEventListener === 'function') {
| |
| document.addEventListener('DOMContentLoaded', addScrollToTopButton, false);
| |
| } else if (typeof document.attachEvent === 'function') {
| |
| document.attachEvent('onreadystatechange', function () {
| |
| if (document.readyState === 'complete') {
| |
| addScrollToTopButton();
| |
| }
| |
| });
| |
| }
| |