1
无法使用Safari上的Storage Access API在iframe中设置Cookie
我的页面上有一个iframe。由于Safari阻止了第三方Cookie,我正在尝试使用“开发人员指南”中此处建议的存储访问API:https : //webkit.org/blog/10218/full-third-party-cookie-blocking-and-more /。我从文档中复制了以下代码: <script type="text/javascript"> window.addEventListener('load', () => { document.getElementById('test-button').addEventListener('click', () => { document.hasStorageAccess().then(hasAccess => { console.log('hasAccess: ' + hasAccess); if (!hasAccess) { return document.requestStorageAccess(); } }).then(_ => { console.log('Now we have first-party storage access!'); document.cookie = "foo=bar"; console.log(`document.cookie: ${document.cookie}`); }).catch(_ => { console.log('error'); }); }); }); </script> <button …