HTML/JavaScript - Elegant welcome image cover that fades out after loading - Does the web page subtly refresh?

After nearly completing my goal of achieving a full-screen welcome image that fades out upon loading and re-enables scrollbars on larger screens, I have encountered an issue. When the image fades out, text and background colors either load or reload, while images and positioning are not affected.

I would greatly appreciate any suggestions or ideas to resolve this problem. My attempts to remove CSS/HTML lead me to believe that the issue lies within the JavaScript code below:

if ($(window).width() > 769) {
   $(window).load(function() {
      var isshow = sessionStorage.getItem('isshow');
      if (isshow== null) {
        sessionStorage.setItem('isshow', 1);
        document.documentElement.style.overflow = 'hidden';  
        document.body.scroll = "no"; 
      
        $.when($('#jPopup').show().delay(4000).fadeOut(2000))
        .done(function() {
            document.documentElement.style.overflow = 'auto';  
            document.body.scroll = "yes"; 
         });
       }
   });
}

I have also experimented with using $(document).ready instead of window.load.

Answer №1

One way to include a completion callback with fadeOut is by passing it directly into the function.

if ($(window).width() > 769) {
  $(document).ready(function() {
    var isshow = sessionStorage.getItem('isshow');
    if (isshow == null) {
      sessionStorage.setItem('isshow', 1);
      document.documentElement.style.overflow = 'hidden';  // firefox, chrome
      document.body.scroll = "no"; // ie only

      $("#jPopup").show().delay(4000).fadeOut(2000, function() {
          // This code will execute after the fadeout is complete
          document.documentElement.style.overflow = 'auto';  // firefox, chrome
          document.body.scroll = "yes"; // ie only
      });
    }
  });
}

To see a working example, click here: http://jsbin.com/liruxilupa

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Disable list-group-item-action clicking

I'm looking to maintain the list-group-item-action hover effect that changes the background color while eliminating the click effect that activates it. Is there a way to achieve this? I've already removed the href="#" from the If I remove list-g ...

flexbox: Two vertical icons tightly aligned without any space

Hey everyone, I've been working on this layout: https://i.sstatic.net/4Aye0.png Here's what I tried so far: Resetting padding and margin in the <a href> and in the <img src...> HTML container <div> <div className="pe ...

"Substitute the dropdown arrow in the select menu with a font awesome

I am currently facing a challenge in my project where I need to customize the select dropdown arrow by replacing it with a FontAwesome icon (specifically chevron-circle-down). While I have found resources on how to replace the background of the dropdown ...

Manipulating CSS styles through Javascript with passed parameters

I need a feature that allows users to pick the color of the buttons displayed on the website. Currently, I am working with Angular 6 and JavaScript to achieve this functionality. I am focusing on setting the primary color, affecting buttons with the Bootst ...

CSS clearfix doesn't appear to be functioning properly

I've been experimenting with using clearfix instead of the clear both property, but it's not working as expected. Despite following tutorials, the issue persists. How can I troubleshoot this and make it function properly? * { marg ...

Ensure that the value in the array is verified using jQuery for errors

HTML <table id="gwForm"> <tbody> <tr data-id="1"></tr> <tr data-id="2"></tr> </tbody> </table> Script var ids = []; $("#gwForm tbody tr").each(function(index, el){ ids.push($(el).data ...

Exploring Laravel 4's CSS Routing

Attempting to connect my CSS document in Laravel 4 has been a bit challenging. The location of my CSS file is: public/css/style.css In the view, I have the following link: <link type="text/css" rel="stylesheet" href="{{URL::asset('css/style.css ...

The Bootstrap 3.3 Carousel is stationary and does not rotate

I am facing a challenge with implementing a Carousel using Bootstrap version 3.3.7 on my website. The code snippet is as follows: <!-- Carousel ================================================== --> <div class="row dark-start d-none d-lg-block"&g ...

Is there a way to stop TinyMCE from adding CDATA to <script> elements and from commenting out <style> elements?

Setting aside the concerns surrounding allowing <script> content within a Web editor, I am fully aware of them. What I am interested in is permitting <style> and <script> elements within the text content. However, every time I attempt to ...

Using node modules within an HTML document

I'm finding it challenging to understand how npm handles dependencies when it comes to referencing them in HTML. For example, if I have a specific version of a plugin installed that includes the version number in its path or file name, and npm is set ...

Invoking a function inside a loop function, within a larger function

It seems like there's a minor syntax issue in my code. Here is a simplified version of it: function example1() { var thumbWidth = $(this).find('img').width(); //some more code }; function example2() { $('div').each(func ...

Deactivating an asp.net label using client-side scripting

Having a web form with numerous controls and a submit button can be tricky. The issue arises when a user initially submits clean data, resulting in the display of a "form submitted successfully" message using an asp.net label control. However, if the same ...

Setting the lang attribute on the html element in Nuxt: A step-by-step guide

Customizing the nuxt.config.js file allows for personalization of the head contents by adding meta tags and other elements: module.exports = { /* ** Headers of the page */ head: { title: 'amazing title', meta: [ { charset: ...

Node.js enables seamless streaming of PCM audio

I'm looking to create a unique sound pattern on a nodejs server and then effectively stream the audio to an http client using express.js. Utilizing the WebAudio API implementation found at https://github.com/mohayonao/web-audio-engine/, I successfull ...

Siblings mousedown event propagation

In my HTML code, I have a division that contains multiple image objects with the position set to absolute. Here is an example: <div> <img> <img> <img> <img> </div> The problem arises when the ...

What is the best way to align a bootstrap 5 iframe in the center?

<div class="ratio ratio-4x3 justify-content-center align-items-center mx-auto"> <iframe src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2Fprofile.php%3Fid%3D100085514265694&tabs=timeline&width=500& ...

Tips for updating the color of table data when the value exceeds 0

I'm currently working on developing a transaction table that is intended to display debit values in red and credit values in green. However, I would like these colors to only be applied if the value in the table data is greater than 0 via JavaScript. ...

What does the error message "unsupported command-line flag" in Chrome mean for Protractor?

Recently jumping on the Protractor bandwagon, I found myself facing an issue while running my tests on Chrome (an error message appears below the address bar in the browser): A worrisome warning popped up saying something about '--ignore-certificat ...

What is the method for uncovering classes that do not have any associated CSS selectors?

Take a look at this snippet of HTML code: <style type="text/css"> .existing-class { background-color: #000; } </style> <div class="existing-class non-existing-class"></div> Within this code, there are two classes applied to the ...

Creating custom shaders for YouTube videos within a Three.js userscript

I want to add a shader effect to YouTube videos. My current approach involves using Three.js to implement a shader on a video. Specifically, I am trying to adapt this example of applying a shader to a video (code available here) into a Tampermonkey usersc ...