I have a simple language dropdown on my site that changes the language inside an iframe. The problem is, whenever i swich to the next page in the iframe the language sets back to its default value, even though the dropdown is still on another language.
HTML:
<input type="checkbox" id="checkbox_English" checked style="display: none">
<input type="checkbox" id="checkbox_German" style="display: none">
<select id="language_Dropdown">
<option value="english">English</option>
<option value="german">Deutsch</option>
</select>
CSS on main page:
#language_Dropdown{
display: block;
margin-left: auto;
margin-right: auto;
border-top: 1px black solid;
border-right: 1px black solid;
border-bottom: 2.5px black solid;
border-left: 1px black solid;
border-radius: 7.5%;
font-family: PixelGosub, Roboto, sans-serif;
color: white;
background-color: black;}
CSS in iFrame:
.english{
display: unset;}
.german{
display: none;}
jQuery:
$(document).ready(function() {
$( "#language_Dropdown" ).change(function() {
var option = $("#language_Dropdown").val();
if (option == "english") {
$( "#checkbox_English" ).prop( "checked", true );
$( "#checkbox_German" ).prop( "checked", false );
var iFrame = $("#iFrame_Content").contents();
iFrame.find(".english").css("display", "unset");
iFrame.find(".german").css("display", "none");
}
else if (option == "german"){
$( "#checkbox_English" ).prop( "checked", false );
$( "#checkbox_German" ).prop( "checked", true );
var iFrame = $("#iFrame_Content").contents();
iFrame.find(".english").css("display", "none");
iFrame.find(".german").css("display", "unset");
}
});
});
I've read i have to use cookies to do that, but i'm pretty new to jQuery and most solutions i looked up were pretty advanced... Is there a more simpler way to just add something to my code to make it work, or am i on a complety wrong track?