Edge或Safari未读取Cookie

问题描述 投票:0回答:1

我遇到了Safari或MS Edge无法读取cookie的问题。它在所有其他浏览器中都运行良好,而不是在这些浏览器中。有没有人遇到过类似的问题?如果是这样,你是如何设法解决的?谢谢。

$('.primary-button.eligibility-button').mousedown(function() {

var selectedCard = $('input[name="cardInterestOption"]:checked').next().text();
var balanceTransferOption = $('input[name="balanceTransferOption"]:checked').next().text().replace(/[a-z]/g,'');
var annualIncome = parseFloat($( "input[name='annualIncome']").val());
var otherIncome = parseFloat($( "input[name='otherIncome']").val());
var totalIncome = annualIncome + otherIncome;
document.cookie = "creditCardSelectorEligibility=" + selectedCard + "; path=/;";
document.cookie = "creditCardBalanceTransfer=" + balanceTransferOption + "; path=/;";
document.cookie = "creditCardTotalIncome=" + totalIncome + "; path=/;";

});

(function() {
var page = "";
var percentage = "NA";
var path = location.pathname;
if(/results/.test(path)){
    page = "Success";
    var results = "";
    var percent = $(".results-banner:eq(0)").text();
    if(/\b[0-9]{2}/.test(percent)){
        results = percent.match(/\b[0-9]{2}/)[0]
    }
}
else if(/verify/.test(path)){
    page = "Verify";
}
else if(/problem/.test(path)){
    page = "Problem";
}
else if(/noteligible/.test(path)){
    page = "Not Eligible";
}
else if(/unavailable/.test(path)){
    page = "Unavailable";
}

var selectedCard = bt_cookie('yrd_creditCardSelectorEligibility')
var balanceTransferOption = bt_cookie('yrd_creditCardBalanceTransfer')
var totalIncome = bt_cookie('yrd_creditCardTotalIncome')

return page + "|" + selectedCard + "|" + balanceTransferOption + "|" + totalIncome + "|" + results;

})();

javascript jquery cookies safari microsoft-edge
1个回答
0
投票

我们有时发现的是,页面加载太快而无法创建cookie。所以我们不得不改变Cookies的创建方式。例如,当用户与表单交互时,您可以更改代码以创建Cookie。即:如果选择一个按钮或填写一个字段。在那里捕获cookie,而不是在客户必须单击提交的页面末尾。希望这有道理吗?

© www.soinside.com 2019 - 2024. All rights reserved.