在这段代码中,我正在检查是否设置了cookie并运行代码以弹出标记选择。如果未设置cookie,则会在检查flaf后设置cookie。它适用于chrome但不适用于firefox。我使用了WC3的代码。有人可以帮我在这里找到问题。提前谢谢。
<script type="text/javascript">
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function checkCookie() {
var languageSet = getCookie("setLanguage");
if (languageSet != "" || languageSet != null) {
return null;
} else {
jQuery.fancybox("#selectFlagDiv");
setCookie("setLanguage", setLanguage, 365);
}
}
</script>
<div id="selectFlagDiv" onload="checkCookie();" style="display:none;">
<a href="https://bennhail.com/shop/?___store=arabic"> <img style="margin-bottom:18px;margin-top:18px;width:300px;height:180px;" src="1.gif" onclick="setLangStorage();" /></a>
<a href="https://bennhail.com/shop/?___store=english"> <img style="margin-bottom:18px;margin-top:18px;width:300px;height:180px;" src="2.gif" onclick="setLangStorage();" /></a>
</div>