Hi there! Iām currently working on creating a website that features a language selection menu. The idea is that when a user chooses a language, a cookie will be set to remember their choice. Upon revisiting the website, JavaScript will automatically redirect the user to the page with content in their chosen language. However, I am facing an issue where the language selection menu briefly appears for 1 second before the page transitions. I would like to have JavaScript perform a location.replace as soon as the page loads. Here's the code snippet: HTML
<!DOCTYPE html>
<html>
<head>
<script src="javascript\indexscript.js""></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" integrity="sha384-aUGj/X2zp5rLCbBxumKTCw2Z50WgIr1vs/PFN4praOTvYXWlVyh2UtNUU0KAUhAX" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="style\indexstylesheet.css">
<script src="javascript\indexscript.js""></script>
</head>
<body onLoad="checkCookie()">
<div id="overlay">
<div id="background">
</div>
<div class="popup-info">
<img class="flag" id="dutch" src="images\dutchflag.png" onclick="nl()">
<img class="flag" id="english" src="images\englishflag.png" onclick="en()">
<div id="textholder">
<h1 class="lang" id="NLtext">Welke taal spreekt u?</h1>
<h1 class="lang" id="ENtext">What language do you speak?</h1>
</div>
</div>
</div>
</div>
</body>
</html>
CSS
#background {
position: fixed;
top: 0px;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.85098);
z-index: 1;
color: white;
margin: 0 auto;
}
.popup-info {
top: 100px;
left: 0;
right: 0;
height: 450px;
width: 800px;
margin: 0 auto;
background: white;
position: fixed;
z-index: 2;
-webkit-border-radius: 25px;
}
/* Rest of the CSS remains unchanged */
JAVASCRIPT
Updated JavaScript functions are included here...