1

I've been working on a website and I recently decided to implement a preloader to my website. I have everything in place but the JavaScript to control the loader does not seem to work.

Here's my code:

As there's quite some code, I have uploaded it on JSFiddle Here it is https://jsfiddle.net/mvc2fe1a/1/

<div class="spinner-wrapper">
    <div class="spinner">
        <svg width="634" height="62" viewBox="0 0 634 62" fill="none" xmlns="http://www.w3.org/2000/svg">
...
        </svg>

    </div>
    </div>
.spinner-wrapper {
    height: 100%;
    width: 100%;
    background: #333;
    position: absolute;
    top: 0;
    left: 0;
}

.spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
function loadPage() {
    let timeout = setTimeout(showPage, 3000);
}

function showPage() {
    document.querySelector('.spinner-wrapper').style.display = 'none'
    document.querySelector('.container').style.display = 'block'
}

However this code does not work, what am I doing wrong?

8
  • You forgot to include the JSFiddle! Commented Nov 15, 2019 at 16:39
  • What do you mean by "doesn't work" that could be a lot of things. Commented Nov 15, 2019 at 16:40
  • I added code instead Commented Nov 15, 2019 at 16:40
  • Also, there are no errors in the console Commented Nov 15, 2019 at 16:40
  • What are you trying to achieve? And what is happening instead? Commented Nov 15, 2019 at 16:40

2 Answers 2

2

You need to call your loadPage function. Right now, you have only defined it.

// other code
loadPage();
Sign up to request clarification or add additional context in comments.

1 Comment

Dude you are a lifesaver
0

You forgot to call the loadPage() function

I edited your Fiddle: https://jsfiddle.net/woma7h83/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.