今天,在 react 項目中使用 iframe,測試 百度網頁OK,但使用生產實際的 URL,出現如下報錯:
報錯內容:Failed to read the 'localStorage' property from 'Window' : Access is denied for this document.
問題場景:
在Iframe 中引入720全景網頁是報錯。
解決辦法:
Under Chrome's Settings > Privacy > Content settings, you have the cookie setting set to to "Block sites from setting any data"
即:
在Chrome設置菜單中: 高級 > 隱私設置和安全性 > 內容設置 > Cookie > 阻止第三方Cookie
將這項關閉,如下圖