Main page disappearing after splash screen loaded.

Jason Phang

Well-known member
Joined
Aug 13, 2019
Messages
46
Programming Experience
Beginner
I have a splash screen created for when I load my program, then the splash screen will be loaded and then after a few seconds, it will be redirected to my main home page. My main issue here is that the splash screen will be shown and then the main page will be shown for a second only before it refreshes and the splash screen loops again. I am not too sure if there is a problem with this block of code. I have tried 2 methods but both produce the same results.

C#:
<div class="preload" id="preload">
    <div class="logo">
        Loa<span style="color: darkturquoise;">ding</span>
    </div>
    <div class="loader-frame">
        <div class="loader1" id="loader1"></div>
        <div class="loader2" id="loader2"></div>
    </div>
</div>
<script type="text/javascript">

    (function () {

        var preload = document.getElementById("preload");
        var loading = 0;
        var id = setInterval(frame, 64);

        function frame() {
            if (loading == 100) {
                clearInterval(id);
                //  window.location.href = "/Home/GetGoogleDriveFiles";
                window.open("/Home/GetGoogleDriveFiles", "_self");
            }
            else {
                loading = loading + 1;
                if (loading == 90) {
                    preload.style.animation = "fadeout 1s ease";
                }
            }
        }
    })();
</script> -->

C#:
<body>
   
    <div class="preload" id="preload">
        <div class="logo">
            Loa<span style="color: darkturquoise;">ding</span>
        </div>
        <div class="loader-frame">
            <div class="loader1" id="loader1"></div>
            <div class="loader2" id="loader2"></div>
        </div>
    </div>

    <script type="text/javascript">
        var timeOutInMilliSeconds = 5000;
        setTimeout(function () {
            location.href = "/Home/GetGoogleDriveFiles";
        }, timeOutInMilliSeconds);
    </script>
       
    <div class="container body-content">
        @RenderBody()
        <hr />
    </div>
    <footer class="center bg-dark">
        <p>Jason Phang Vern - Onn &copy; 2019</p>
    </footer>
</body>
</html>

Both of these loops the screen and only display my page for less than a second.
 
You essentially have a JavaScript/HTML problem. This is a C# forum.
 
Fair point, but OP is still using Mvc.Razor namespace which makes this category suitable for the question.

OP, note that your timers are measured in miliseconds and not seconds. I'm also curious how much relevant code is commented out
Your first function doesn't use a timer
(function () {
Give up the shotgun approach to learning. I detest it. Learn the language and stop using code from the net you don't know how it works.
Also looks like our OP is taking advice from that oh so terrible site again Splash screen keep refreshing itself in ASP.NET
 
Back
Top Bottom