我正在做一个镀铬的分机,里面有一个iframe。当扩展请求到服务器以获取页面时,它将返回一个错误
Refused to display 'https://subdomain.example.com/' in a frame because it set 'X-Frame-Options' to 'deny'
。虽然我已经在我的
x-frame-options
文件中将
deny
设置为
deny
,并且在后端项目中的特定方法中添加了一个
header('x-frame-options: GOFORIT')
,但它返回了另一个错误
Refused to display 'https://subdomain.example.com/' in a frame because it set multiple 'X-Frame-Options' headers with conflicting values ('GOFORIT, DENY'). Falling back to 'deny'
。我将
webRequest
和
webRequestBlocking
添加到
webRequestBlocking
文件中的
permissions
中。没有运气,它返回了
'webRequestBlocking' requires manifest version of 2 or lower
和
Unchecked runtime.lastError: You do not have permission to use blocking webRequest listeners. Be sure to declare the webRequestBlocking permission in your manifest.
,所以我从权限中删除了
webRequestBlocking
,并添加了与v3一样的
declarativeNetRequest
。没有结果!!然后我又说
代码语言:
javascript
复制
chrome.webRequest.onHeadersReceived.addListener(
function(info) {
var headers = info.responseHeaders;
for (var i=headers.length-1; i>=0; --i) {
var header = headers[i].name.toLowerCase();
if (header == 'x-frame-options' || header == 'frame-options') {
headers.splice(i, 1); // Remove header
return {responseHeaders: headers};
urls: [
'*://*/*', // Pattern to match all http(s) pages
// '*://*.example.org/*', // Pattern to match one http(s) site
types: [ 'sub_frame' ]
'blocking',