mercredi 23 décembre 2020

How to delay javascript reload function on orientation change

I am using a forced page reload on orientation change of the website and would like the page refresh to occur 5 seconds after the rotation occurs, but I cannot seem to put the timeout in the correct place.

Here is my code as it stands.

<script type="text/javascript"> // RELOADS WEBPAGE WHEN MOBILE ORIENTATION CHANGES  
    window.onorientationchange = function() { 
        var orientation = window.orientation; 
            switch(orientation) { 
                case 0:
                case 90:
                case -90: window.location.reload(); 
                break; } 
    };

Thank you so much in advance for any help!




Aucun commentaire:

Enregistrer un commentaire