// web响应
chrome.webRequest.onHeadersReceived.addListener(
  (details) => {
    let responseHeaders = details.responseHeaders
    console.log('details', responseHeaders)
    let index = responseHeaders.findIndex((p) => p.name.toLowerCase() === 'x-frame-options')
    if (index > -1) {
      responseHeaders.splice(index, 1)
      console.log('删除 x-frame-options', responseHeaders)
    }

    return { responseHeaders }
  },
  { urls: ['<all_urls>'], types: ['main_frame', 'sub_frame'] },
  ['blocking', 'responseHeaders']
)
  

浏览器 f12 查看发现响应头 ,并没有变化,这时候  不要着急。  

 

把原本不允许 签入 iframe 的页面签入 进入 iframe 发现浏览器已经不报错了,至此就明白了,原来f12 查看到的响应头已经 失效了

 

相关文章:

  • 2021-12-15
  • 2021-05-10
  • 2021-05-01
  • 2021-07-26
  • 2022-01-03
  • 2021-12-01
  • 2021-12-26
  • 2022-01-10
猜你喜欢
  • 2022-02-02
  • 2021-05-07
  • 2021-12-12
  • 2021-12-30
  • 2021-12-15
相关资源
相似解决方案